:root {
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --surface-2: #FAFBFD;
  --line: #E4E9F0;
  --line-2: #EEF2F7;
  --ink: #101828;
  --ink-2: #5B6B7F;
  --ink-3: #94A3B5;
  --brand: #185FA5;
  --brand-2: #0C447C;
  --brand-soft: #E6F1FB;
  --brand-line: #B5D4F4;
  --ok: #0F6E56;
  --ok-soft: #E1F5EE;
  --ok-line: #9FE1CB;
  --warn: #854F0B;
  --warn-soft: #FAEEDA;
  --warn-line: #FAC775;
  --bad: #A32D2D;
  --bad-soft: #FCEBEB;
  --bad-line: #F7C1C1;
  --r: 10px;
  --r-lg: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 500; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* ---------- 登录闸门 ---------- */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 50% -10%, #E6F1FB 0%, transparent 70%),
    var(--bg);
}
.gate-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
}
.gate-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.5px;
  margin-bottom: 20px;
}
.gate-card h1 { font-size: 19px; letter-spacing: -0.2px; }
.gate-sub { color: var(--ink-2); font-size: 13px; margin-top: 6px; }
.gate-field { margin-top: 24px; }
.gate-field label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.gate-field input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
.gate-field input:focus { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.gate-note {
  margin-top: 16px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-3);
  border-top: 1px solid var(--line-2);
  padding-top: 14px;
}

/* ---------- 外壳 ---------- */
.shell { display: flex; min-height: 100vh; }

.side {
  width: 216px;
  flex: 0 0 216px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  padding: 20px 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 500;
}
.brand-text { line-height: 1.25; }
.brand-text b { font-size: 13px; font-weight: 500; display: block; }
.brand-text span { font-size: 11px; color: var(--ink-3); }

.nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 13px;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand-2); font-weight: 500; }
.nav a .ico { width: 16px; height: 16px; flex: 0 0 16px; opacity: .85; }
.nav .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-3);
  background: var(--line-2);
  border-radius: 20px;
  padding: 0 7px;
  line-height: 18px;
}
.nav a.on .count { background: #fff; color: var(--brand-2); }

.side-foot {
  margin-top: auto;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line-2);
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.7;
}
.side-foot b { color: var(--ink-2); font-weight: 500; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 28px 16px;
}
.topbar h1 { font-size: 18px; letter-spacing: -0.3px; }
.topbar .sub { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  white-space: nowrap;
}
.pill.demo { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }

.user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  font-size: 12px;
  color: var(--ink-2);
}
.user .av {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-2);
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 500;
}
.user .out { color: var(--ink-3); cursor: pointer; padding-left: 4px; }
.user .out:hover { color: var(--bad); }

.view { padding: 0 28px 48px; flex: 1; }

/* ---------- 通用 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.panel { padding: 18px 20px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { font-size: 14px; }
.panel-head .hint { font-size: 12px; color: var(--ink-3); }

.btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand-line); color: var(--brand-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:disabled {
  background: var(--line);
  border-color: var(--line);
  color: var(--ink-3);
  cursor: not-allowed;
}
.btn.wide { width: 100%; height: 40px; }
.btn.sm { height: 26px; padding: 0 10px; font-size: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1;
  background: var(--line-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--brand-soft); color: var(--brand-2); }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot.ok { background: #5DCAA5; }
.dot.warn { background: #EF9F27; }
.dot.bad { background: #E24B4A; }
.dot.idle { background: #CBD5E1; }

/* ---------- KPI ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi { padding: 14px 16px; }
.kpi .k { font-size: 12px; color: var(--ink-2); }
.kpi .v { font-size: 24px; font-weight: 500; letter-spacing: -0.5px; margin-top: 2px; }
.kpi .m { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.kpi .v small { font-size: 13px; font-weight: 400; color: var(--ink-3); margin-left: 2px; }

/* ---------- 缺口告警 ---------- */
.gaps { display: flex; flex-wrap: wrap; gap: 8px; }
.gap-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--bad-line);
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 12px;
  cursor: pointer;
}
.gap-chip:hover { filter: brightness(.98); }
.gap-chip b { font-weight: 500; }
.gap-chip .n {
  background: #fff;
  border-radius: 20px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 17px;
}
.gap-chip.muted { border-color: var(--line); background: var(--surface-2); color: var(--ink-2); cursor: default; }

/* ---------- 站点矩阵 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(246px, 1fr));
  gap: 12px;
}
.site-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px 13px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .12s, transform .12s;
}
.site-card:hover { border-color: var(--brand-line); transform: translateY(-1px); }
.site-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--c, var(--brand));
}
.site-card .sc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.site-card .sc-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-card .sc-slug { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.site-card .sc-domain { font-size: 11px; color: var(--ink-2); margin-top: 5px; font-family: var(--mono); }
.site-card .sc-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--line-2);
  font-size: 11px;
  color: var(--ink-2);
}
.site-card .sc-stats b { font-weight: 500; color: var(--ink); }
.site-card .sc-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }

/* ---------- 投递台 ---------- */
.inbox { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1080px) { .inbox { grid-template-columns: 1fr; } }

.drop {
  width: 100%;
  min-height: 116px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
  outline: none;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.9;
}
.drop:focus { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.drop::placeholder { color: var(--ink-3); font-family: inherit; }

.detected { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.drow {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 11px 13px;
  background: var(--surface-2);
}
.drow.low { border-color: var(--warn-line); background: #FFFCF5; }
.drow .d-url {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drow .d-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.drow .d-type {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--brand-2);
  background: var(--brand-soft);
  border-radius: 5px;
  padding: 1px 6px;
}
.drow select {
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  padding: 0 6px;
  outline: none;
}
.drow .conf { font-size: 11px; color: var(--ink-3); margin-left: auto; }

.howto { font-size: 12px; color: var(--ink-2); line-height: 1.9; }
.howto code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--line-2);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink);
}

/* ---------- 任务 ---------- */
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
}
.task-row:hover { border-color: var(--brand-line); }
.task-row .t-main { min-width: 0; flex: 1; }
.task-row .t-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row .t-meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; font-family: var(--mono); }

/* ---------- 运行详情 ---------- */
.run-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1080px) { .run-grid { grid-template-columns: 1fr; } }

.steps { display: flex; flex-direction: column; }
.step {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  position: relative;
}
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 26px;
  bottom: -3px;
  width: 1px;
  background: var(--line);
}
.step .st-ico {
  width: 17px; height: 17px;
  flex: 0 0 17px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid; place-items: center;
  font-size: 9px;
  color: var(--ink-3);
  z-index: 1;
  margin-top: 3px;
}
.step.done .st-ico { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.step.run .st-ico { border-color: var(--brand); color: var(--brand); }
.step.run .st-ico::after {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--brand);
  border-top-color: transparent;
  animation: spin .7s linear infinite;
}
.step.skip .st-ico { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.step.fail .st-ico { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
@keyframes spin { to { transform: rotate(360deg); } }

.step .st-body { min-width: 0; flex: 1; }
.step .st-name { font-size: 12.5px; color: var(--ink); }
.step.pending .st-name { color: var(--ink-3); }
.step .st-note { font-size: 11px; color: var(--ink-3); font-family: var(--mono); margin-top: 1px; }
.step .st-ms { font-size: 11px; color: var(--ink-3); margin-left: 6px; }

.log {
  background: #0F1720;
  border-radius: var(--r);
  padding: 12px 14px;
  height: 380px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.85;
  color: #C7D2DD;
  white-space: pre-wrap;
  word-break: break-all;
}
.log .l-t { color: #5E7285; }
.log .l-ok { color: #6FD3A8; }
.log .l-warn { color: #F0B859; }
.log .l-err { color: #F0908F; }
.log .l-dim { color: #7D8FA0; }

.gates { display: flex; flex-direction: column; gap: 6px; }
.gate-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
}
.gate-row.pass { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.gate-row.idle { color: var(--ink-3); }
.gate-row .g-n { margin-left: auto; font-family: var(--mono); font-size: 11px; opacity: .8; }

.progress { height: 3px; background: var(--line-2); border-radius: 3px; overflow: hidden; margin: 0 0 14px; }
.progress i { display: block; height: 100%; background: var(--brand); transition: width .3s; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left;
  font-weight: 400;
  color: var(--ink-3);
  font-size: 11px;
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table .mono { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 站点详情 ---------- */
.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.detail-head::before {
  content: "";
  position: absolute;
  left: 0; top: 0; right: 0;
  height: 3px;
  background: var(--c, var(--brand));
}
.detail-head .dh-mark {
  width: 42px; height: 42px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: var(--c, var(--brand));
  flex: 0 0 42px;
}
.detail-head .dh-main { flex: 1; min-width: 0; }
.detail-head h2 { font-size: 15px; }
.detail-head .dh-sub { font-size: 12px; color: var(--ink-2); font-family: var(--mono); margin-top: 2px; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: var(--line-2);
  border-radius: var(--r);
  overflow: hidden;
}
.meta-item { background: var(--surface); padding: 11px 13px; }
.meta-item .mk { font-size: 11px; color: var(--ink-3); }
.meta-item .mv { font-size: 12.5px; margin-top: 2px; font-family: var(--mono); word-break: break-all; }
.meta-item .mv.plain { font-family: inherit; }

.art-list { display: flex; flex-direction: column; }
.art-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 12.5px;
}
.art-row:last-child { border-bottom: 0; }
.art-row .a-date { font-family: var(--mono); font-size: 11px; color: var(--ink-3); flex: 0 0 72px; }
.art-row .a-title { flex: 1; min-width: 0; }

.section-title {
  font-size: 12px;
  color: var(--ink-3);
  margin: 22px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}
.empty b { display: block; color: var(--ink-2); font-weight: 500; margin-bottom: 4px; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 900px) { .row2 { grid-template-columns: 1fr; } }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.muted { color: var(--ink-3); }
.hidden { display: none !important; }
