:root {
  --bg: #eef4fb;
  --panel: #ffffff;
  --line: #dbe6f2;
  --text: #172033;
  --muted: #6b778c;
  --blue: #1677ff;
  --blue-dark: #0f5ed8;
  --danger: #ff4d4f;
  --soft-blue: #e7f1ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.sidebar {
  width: 232px;
  min-height: 100vh;
  padding: 22px 16px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 6px; }
.brand-icon {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 8px; background: var(--blue); color: #fff; font-weight: 700;
}
.brand strong, .brand span { display: block; }
.brand span { color: var(--muted); font-size: 12px; }

nav { display: grid; gap: 8px; }
button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: #f5f8fc;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
button:hover { background: #eaf2fd; }
button.active, button.primary {
  background: var(--blue);
  color: #fff;
}
button.primary:hover { background: var(--blue-dark); }
button.danger { color: var(--danger); background: #fff1f0; }
button.ghost { margin-top: auto; color: var(--muted); background: transparent; }

main { flex: 1; padding: 28px; overflow: auto; }
.hidden { display: none !important; }
.legacy-hidden { display: none; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 26px; }
h2 { margin-bottom: 0; font-size: 18px; }
p { color: var(--muted); }
.actions { display: flex; gap: 10px; }

.login-card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(20, 52, 95, .06);
}
.login-card { width: min(440px, 100%); padding: 28px; margin: 12vh auto; }
.grid { display: grid; grid-template-columns: 390px minmax(0, 1fr); gap: 18px; }
.panel { padding: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head span { color: var(--muted); }

.site-list { display: grid; gap: 10px; }
.site-item {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdff;
}
.site-item.active { background: var(--soft-blue); border-color: #8dc1ff; }
.site-domain { font-weight: 700; color: var(--blue); overflow-wrap: anywhere; }

.form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: var(--muted); }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #f9fbfe;
  font: inherit;
}
textarea { resize: vertical; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
input[type=color] { min-height: 42px; padding: 4px; }
.switch-list { display: flex; flex-wrap: wrap; gap: 10px; }
.switch-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}

.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { background: var(--soft-blue); padding: 12px; border-radius: 8px; min-width: 120px; }
.stat strong { display: block; font-size: 22px; }
.table { display: grid; gap: 8px; }
.row { display: grid; gap: 4px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.row code { overflow-wrap: anywhere; }

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(440px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(18, 28, 45, .42); }
.dialog-form { padding: 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

.notice { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }
.notice.danger { color: #7a1d1d; background: #fff1f0; }
#toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: .18s ease;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }

.hero-card {
  position: relative;
  min-height: 164px;
  border-radius: 10px;
  margin-bottom: 18px;
  background: linear-gradient(180deg, #8bc6ff 0%, #eef7ff 78%, #fff 100%);
  border: 1px solid #d9e9fb;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.hero-title { text-align: center; }
.hero-title h1 { font-size: 24px; margin: 0 0 4px; }
.hero-title p { margin: 0; font-size: 13px; color: #6b86a5; }
.hero-stats {
  display: flex;
  align-items: center;
  gap: 34px;
  margin-top: 22px;
}
.hero-stats div { display: grid; justify-items: center; }
.hero-stats strong { font-size: 30px; line-height: 1; }
.hero-stats strong.free { color: #ff3b47; }
.hero-stats span { color: #7a8ca5; font-size: 12px; margin-top: 6px; }
.hero-stats i { width: 1px; height: 42px; background: #d7e5f5; }
.pill {
  position: absolute;
  top: 24px;
  right: 26px;
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  box-shadow: 0 10px 22px rgba(22, 119, 255, .16);
}

.quick-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 18px;
}
.quick-panel button {
  height: 70px;
  background: #fff;
  color: #253656;
}
.quick-panel button span {
  display: block;
  color: var(--blue);
  font-size: 24px;
  line-height: 1;
  margin-bottom: 5px;
}

.agent-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}
.soft-primary {
  border-radius: 999px;
  background: #edf5ff;
  color: var(--blue);
  font-weight: 700;
}
.manage-wrap { display: grid; gap: 18px; }
.config-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  color: #8a99ad;
  font-size: 13px;
}
.config-divider span { height: 1px; background: #e8eef6; }
.config-divider em { font-style: normal; }
.old-form {
  gap: 18px;
}
.config-section {
  display: grid;
  gap: 12px;
}
.config-section h3 {
  margin: 0;
  padding-left: 10px;
  border-left: 3px solid var(--blue);
  color: #20314f;
  font-size: 16px;
}
.upload-box {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #8795a9;
}
.upload-box b {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f0f5fb;
  color: #9aabc1;
}
.upload-box.wide { min-height: 76px; }
.color-row input[type=color] {
  height: 44px;
  border-radius: 8px;
}
.save-wide {
  width: 100%;
  min-height: 46px;
  font-weight: 700;
}

@media (max-width: 900px) {
  body { display: block; }
  .sidebar { width: 100%; min-height: auto; }
  main { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .three { grid-template-columns: 1fr; }
}
