:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #121826;
  --muted: #647083;
  --line: #d8dee9;
  --blue: #1769d1;
  --blue-dark: #0a3770;
  --green: #10845b;
  --yellow: #c98600;
  --red: #be3b3b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button, input, select, textarea { font: inherit; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  background: #071a33;
  color: #d9e7f8;
  padding: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 22px;
}

.logo {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.brand strong { display: block; color: #fff; }
.brand span { display: block; color: #9db1ca; font-size: 12px; }

.nav { display: grid; gap: 8px; }

.nav button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 0 12px;
  text-align: left;
  color: #d9e7f8;
  background: transparent;
  cursor: pointer;
}

.nav button.active, .nav button:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

.main { min-width: 0; }

.topbar {
  min-height: 74px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 24px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 3;
}

.topbar h1 { margin: 0; font-size: 22px; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 7px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.small { min-height: 30px; padding: 0 9px; font-size: 12px; }

.content { padding: 24px; }
.section { display: none; }
.section.active { display: block; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 16px;
  min-height: 116px;
}

.metric span { color: var(--muted); font-size: 13px; }
.metric b { display: block; margin-top: 10px; font-size: 28px; }
.metric small { color: var(--green); font-weight: 700; }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, .85fr);
  gap: 16px;
}

.panel { overflow: hidden; margin-bottom: 16px; }

.panel-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.panel-head h2 { margin: 0; font-size: 18px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.panel-body { padding: 18px; }

.cards, .list { display: grid; gap: 10px; }

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcff;
  padding: 14px;
}

.row strong { display: block; }
.row span, .muted { color: var(--muted); font-size: 13px; }

.task-row { align-items: start; }

.task-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

details {
  margin-top: 10px;
  color: var(--muted);
}

summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

details pre {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 260px;
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 7px;
  background: #eef3f9;
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.green { color: var(--green); background: #e8f7f1; }
.badge.blue { color: var(--blue-dark); background: #eaf2ff; }
.badge.yellow { color: #8a5f00; background: #fff5d8; }
.badge.red { color: var(--red); background: #ffeaea; }

.form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

textarea { min-height: 112px; resize: vertical; }
.full { grid-column: 1 / -1; }

.output {
  white-space: pre-wrap;
  background: #07192f;
  color: #dbeafe;
  border-radius: 8px;
  padding: 16px;
  min-height: 180px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  overflow: auto;
}

.score {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  background: conic-gradient(var(--blue) 0 72%, #e7edf5 72% 100%);
}

.score div {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  font-size: 24px;
  font-weight: 800;
}

.channels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.channel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  min-height: 124px;
}

.channel h3 { margin: 0 0 8px; font-size: 16px; }
.channel p { margin: 0; color: var(--muted); font-size: 13px; }

@media (max-width: 1050px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .metrics, .grid, .channels { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .topbar { display: block; }
  .actions { margin-top: 12px; }
  .content { padding: 14px; }
  .form, .row { grid-template-columns: 1fr; }
  .task-actions { justify-content: flex-start; }
}
