/* ---------------------------------------------------------------- 基础 */
:root {
  --bg: #0a0c10;
  --bg-soft: #0f1216;
  --panel: #14181f;
  --panel-2: #191e27;
  --line: #242a35;
  --line-soft: #1d232c;
  --text: #e9edf2;
  --muted: #98a2b0;
  --muted-2: #6f7a88;
  --yolk: #f4c95d;
  --yolk-strong: #ffd97a;
  --yolk-dim: rgba(244, 201, 93, 0.13);
  --green: #4ec9a0;
  --green-dim: rgba(78, 201, 160, 0.13);
  --red: #f2726f;
  --red-dim: rgba(242, 114, 111, 0.13);
  --amber: #e5a44c;
  --amber-dim: rgba(229, 164, 76, 0.14);
  --radius: 18px;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--yolk); text-decoration: none; }
a:hover { color: var(--yolk-strong); }

.hidden { display: none !important; }

.bg-glow {
  position: fixed;
  inset: -30% -10% auto -10%;
  height: 70vh;
  background:
    radial-gradient(45% 55% at 22% 0%, rgba(244, 201, 93, 0.14), transparent 70%),
    radial-gradient(40% 50% at 78% 8%, rgba(120, 160, 255, 0.09), transparent 70%);
  pointer-events: none;
  z-index: 0;
  filter: blur(6px);
}

/* ---------------------------------------------------------------- 登录 */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(60% 60% at 50% 20%, #151a22, #080a0d 75%);
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 34px 28px 26px;
  background: linear-gradient(180deg, #171b23, #101319);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card h1 {
  margin: 12px 0 2px;
  font-size: 24px;
  letter-spacing: 0.04em;
}

.login-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.egg-logo {
  font-size: 40px;
  line-height: 1;
  filter: drop-shadow(0 6px 14px rgba(244, 201, 93, 0.35));
}

.egg-logo.small { font-size: 22px; }

.field {
  display: block;
  text-align: left;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  color: var(--text);
  background: #0c0f14;
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(244, 201, 93, 0.55);
  box-shadow: 0 0 0 3px rgba(244, 201, 93, 0.1);
}

.login-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--red);
  font-size: 13px;
}

.login-hint {
  margin: 12px 0 0;
  color: var(--muted-2);
  font-size: 12px;
}

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn:hover { border-color: #333c4a; background: #1d232d; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  color: #171207;
  background: linear-gradient(180deg, var(--yolk-strong), var(--yolk));
  border-color: rgba(0, 0, 0, 0.15);
  font-weight: 650;
}

.btn.primary:hover { filter: brightness(1.06); }

.btn.ghost { background: rgba(255, 255, 255, 0.03); }

.btn.danger {
  color: var(--red);
  border-color: rgba(242, 114, 111, 0.35);
  background: var(--red-dim);
}

.btn.danger:hover { background: rgba(242, 114, 111, 0.2); }

.btn.block { width: 100%; padding: 12px; font-size: 15px; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 9px; }
.btn.icon { padding: 9px 11px; }
.spacer { flex: 1; }

.spin {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 顶栏 */
.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 12, 16, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.topbar-inner {
  max-width: 1220px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-text { display: flex; align-items: baseline; gap: 8px; }
.brand-text strong { font-size: 17px; letter-spacing: 0.03em; }

.version {
  color: var(--muted-2);
  font-size: 11px;
  font-family: var(--mono);
}

.stats {
  display: flex;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 11px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

.stat b {
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.stat.egg b { color: var(--yolk); }

.top-actions { display: flex; gap: 8px; }

/* ---------------------------------------------------------------- 布局 */
.container {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 26px 24px 60px;
  flex: 1;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search { position: relative; flex: 1; min-width: 220px; max-width: 360px; }

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  font-size: 16px;
  pointer-events: none;
}

.search input { padding-left: 34px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.tab {
  padding: 7px 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }

.tab.active {
  color: var(--yolk);
  background: var(--yolk-dim);
  border-color: rgba(244, 201, 93, 0.28);
}

/* ---------------------------------------------------------------- 卡片 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 18px 18px 14px;
  background: linear-gradient(180deg, #161a21, #101318);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  animation: rise 0.35s ease backwards;
}

.card:hover {
  border-color: #303845;
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}

.card.joined {
  border-color: rgba(244, 201, 93, 0.22);
}

.card.problem {
  border-color: rgba(242, 114, 111, 0.3);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

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

.card-title h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.title-btn {
  padding: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.title-btn:hover { color: var(--yolk); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--muted-2);
}

.dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-dim); }
.dot.warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-dim); }
.dot.idle { background: #4a5361; }
.dot.paused { background: #4a5361; }

.chip {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  white-space: nowrap;
}

.chip.region { color: #9fb4d8; background: rgba(120, 160, 255, 0.08); border-color: rgba(120, 160, 255, 0.16); }
.chip.region.cn { color: #f2b8a0; background: rgba(242, 160, 120, 0.08); border-color: rgba(242, 160, 120, 0.16); }
.chip.ok { color: var(--green); background: var(--green-dim); border-color: rgba(78, 201, 160, 0.22); }
.chip.bad { color: var(--red); background: var(--red-dim); border-color: rgba(242, 114, 111, 0.22); }
.chip.warn { color: var(--amber); background: var(--amber-dim); border-color: rgba(229, 164, 76, 0.22); }

.card-value {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 2px;
}

.card-value b { color: var(--yolk); font-size: 15px; }

.headline {
  margin: 2px 0 8px;
  font-size: 13.5px;
  color: #d7c9a4;
  line-height: 1.55;
}

.detail {
  margin: 0 0 10px;
  font-size: 12.8px;
  color: var(--muted);
  line-height: 1.62;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail.open { -webkit-line-clamp: unset; display: block; }

.more {
  align-self: flex-start;
  margin: -4px 0 10px;
  padding: 0;
  color: var(--muted-2);
  background: none;
  border: none;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.more:hover { color: var(--yolk); }

.meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 10px 0 11px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  margin-top: auto;
}

.meta > div { min-width: 0; }
.meta .k { display: block; font-size: 10.5px; color: var(--muted-2); letter-spacing: 0.05em; }
.meta .v {
  display: block;
  font-size: 12.6px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta .v.dim { color: var(--muted-2); }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px 0 2px;
  min-height: 26px;
}

.tag {
  padding: 1px 7px;
  font-size: 10.5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 10px;
  flex-wrap: wrap;
}

.card-actions .spacer { flex: 1; }

.link-btn {
  padding: 0;
  color: var(--muted-2);
  background: none;
  border: none;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.link-btn:hover { color: var(--red); }

/* ---------------------------------------------------------------- 面板 */
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 30px;
}

.panel {
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.timeline, .events { list-style: none; margin: 0; padding: 0; }

.timeline li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 13px;
}

.timeline li:last-child { border-bottom: none; }

.timeline .when {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--yolk);
  min-width: 92px;
}

.timeline .who { color: var(--text); flex: 1; }
.timeline .left { color: var(--muted-2); font-size: 11.5px; white-space: nowrap; }

.events li {
  display: flex;
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 12.8px;
  color: var(--muted);
  line-height: 1.55;
}

.events li:last-child { border-bottom: none; }
.events .ico { flex: none; opacity: 0.9; }
.events .when { margin-left: auto; color: var(--muted-2); font-size: 11px; white-space: nowrap; padding-left: 8px; }

.empty-panel { color: var(--muted-2); font-size: 12.5px; margin: 4px 0; }

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--muted-2);
}

/* ---------------------------------------------------------------- 页脚 */
.footer {
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted-2);
  font-size: 11.5px;
}

/* ---------------------------------------------------------------- 弹窗 */
#modal-root { position: relative; z-index: 60; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 6, 9, 0.72);
  backdrop-filter: blur(6px);
  animation: fade 0.18s ease both;
  overflow-y: auto;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 24px 20px;
  background: linear-gradient(180deg, #191e26, #12151b);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: pop 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }

.modal.wide { max-width: 680px; }

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.modal-head h2 { margin: 0; font-size: 18px; }

.modal-sub { margin: 2px 0 16px; color: var(--muted); font-size: 12.8px; }

.modal-close {
  padding: 4px 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  font-size: 15px;
  line-height: 1.4;
  cursor: pointer;
}

.modal-close:hover { color: var(--text); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted-2);
  line-height: 1.55;
}

.hint a { text-decoration: underline; text-underline-offset: 2px; }

.notice {
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 12.4px;
  color: #e8dcc0;
  background: rgba(244, 201, 93, 0.07);
  border: 1px solid rgba(244, 201, 93, 0.18);
  border-left: 3px solid var(--yolk);
  border-radius: 10px;
  line-height: 1.6;
}

.section-label {
  margin: 20px 0 8px;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 13.5px;
}

.switch-row:last-child { border-bottom: none; }
.switch-row .desc { display: block; color: var(--muted-2); font-size: 11.5px; }

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex: none;
  border-radius: 999px;
  background: #2a313c;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.18s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #8593a5;
  transition: transform 0.18s, background 0.18s;
}

.switch.on { background: rgba(244, 201, 93, 0.28); border-color: rgba(244, 201, 93, 0.45); }
.switch.on::after { transform: translateX(18px); background: var(--yolk); }

.channel {
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.channel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.channel-head select { width: auto; flex: 1; padding: 7px 10px; font-size: 12.5px; }

.channel-remove {
  padding: 4px 8px;
  color: var(--muted-2);
  background: none;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}

.channel-remove:hover { color: var(--red); border-color: rgba(242, 114, 111, 0.4); }

.channel .field { margin-bottom: 8px; }
.channel .field:last-child { margin-bottom: 0; }
.channel .field > span { font-size: 11px; }

.test-result {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}

.test-result .ok { color: var(--green); }
.test-result .bad { color: var(--red); }

/* ---------------------------------------------------------------- Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  z-index: 80;
  max-width: min(90vw, 460px);
  padding: 11px 18px;
  background: #1c222c;
  border: 1px solid var(--line);
  border-left: 3px solid var(--yolk);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }

/* ---------------------------------------------------------------- 响应式 */
@media (max-width: 900px) {
  .panels { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .stats { order: 3; width: 100%; }
  .top-actions { margin-left: auto; }
  .container { padding: 20px 16px 48px; }
}

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .search { max-width: none; }
  .form-row { grid-template-columns: 1fr; }
  .stat { padding: 4px 9px; }
  .modal { padding: 18px; max-height: 92vh; }
  .top-actions .btn.ghost.icon { display: none; }
  .meta { grid-template-columns: 1fr 1fr; }
}
