:root {
  /* Light pastel palette */
  --bg: #f6f5fb;
  --bg-tint: #efeafc;
  --panel: #ffffff;
  --panel-2: #f4f2fb;
  --border: #ece8f6;
  --text: #2f2b43;
  --muted: #8b86a6;

  /* Pastel accents */
  --accent: #a99bf5;       /* lavender */
  --accent-2: #f7b7d4;     /* pink */
  --lav: #ece7fe;
  --mint: #cdeede;
  --mint-ink: #2f8f6b;
  --peach: #ffe3d0;
  --peach-ink: #c9743a;
  --rose: #ffd9e2;
  --rose-ink: #c65a7e;
  --sky: #d6e8ff;
  --sky-ink: #4f79c4;

  --green: #57c79a;
  --amber: #e6a94e;
  --red: #ef7b93;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(138, 128, 190, 0.14);
  --shadow-sm: 0 4px 14px rgba(138, 128, 190, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background:
    radial-gradient(1100px 600px at 12% -8%, #efe6ff 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #ffe9f3 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 30px;
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 24px;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: 0.2px; }
.brand-sub { color: var(--muted); font-size: 12px; }

.conn { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--green); box-shadow: 0 0 0 4px rgba(87, 199, 154, 0.18); }
.dot.off { background: var(--red); box-shadow: 0 0 0 4px rgba(239, 123, 147, 0.18); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  padding: 24px 30px 6px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat .n { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; }
.stat .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; margin-top: 2px; }
.stat.alert { background: linear-gradient(135deg, #fff, var(--peach)); }
.stat.alert .n { color: var(--peach-ink); }

.grid {
  display: grid;
  grid-template-columns: 320px minmax(320px, 1fr) minmax(360px, 1.2fr);
  gap: 24px;
  padding: 20px 30px 48px;
  align-items: start;
}
.col { min-width: 0; }
.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--muted);
  font-weight: 600;
  margin: 16px 4px 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.cards { display: flex; flex-direction: column; gap: 14px; }

.device {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, box-shadow 0.12s;
}
.device:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.device .avatar {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, var(--lav), var(--sky));
}
.device .meta { flex: 1; min-width: 0; }
.device .id { font-weight: 600; }
.device .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  color: var(--muted); background: var(--panel-2); font-weight: 500;
}
.pill.on { color: var(--mint-ink); background: var(--mint); }
.pill.off { color: var(--rose-ink); background: var(--rose); }
.pill.busy { color: var(--peach-ink); background: var(--peach); }

.tasks { display: flex; flex-direction: column; gap: 14px; }
.task {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, box-shadow 0.12s;
}
.task:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.task.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset, var(--shadow); }
.task .goal { font-weight: 650; margin-bottom: 8px; line-height: 1.35; }
.task .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  color: var(--muted); background: var(--panel-2); text-transform: capitalize; font-weight: 500;
}
.badge.planning, .badge.running { color: var(--sky-ink); background: var(--sky); }
.badge.waiting_hitl { color: var(--peach-ink); background: var(--peach); }
.badge.completed { color: var(--mint-ink); background: var(--mint); }
.badge.failed, .badge.aborted { color: var(--rose-ink); background: var(--rose); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--muted); }

.progressbar { height: 6px; background: var(--panel-2); border-radius: 6px; margin-top: 12px; overflow: hidden; }
.progressbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.3s; border-radius: 6px; }

.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 15px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.12s, filter 0.12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; color: #fff; font-weight: 650;
  box-shadow: 0 6px 18px rgba(169, 155, 245, 0.4);
}
.btn.approve { background: var(--mint); border-color: transparent; color: var(--mint-ink); }
.btn.deny { background: var(--rose); border-color: transparent; color: var(--rose-ink); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(169, 155, 245, 0.18);
  background: #fff;
}
.field input:disabled { color: var(--muted); }
.field textarea { resize: vertical; min-height: 62px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.detail.empty { color: var(--muted); text-align: center; padding: 48px 16px; }
.detail h3 { margin: 0 0 4px; }
.detail .sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13px; margin-bottom: 18px; }
.kv .k { color: var(--muted); }

.approve-box {
  background: linear-gradient(135deg, #fff, var(--peach));
  border: 1px solid transparent;
  border-radius: 16px; padding: 16px; margin: 14px 0;
  box-shadow: var(--shadow-sm);
}
.approve-box .t { color: var(--peach-ink); font-weight: 650; margin-bottom: 6px; }
.approve-actions { display: flex; gap: 10px; margin-top: 12px; }

.plan { list-style: none; padding: 0; margin: 0 0 18px; }
.plan li { display: flex; gap: 10px; padding: 8px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.plan li:last-child { border-bottom: none; }
.plan li .n {
  color: #fff; font-weight: 650; min-width: 22px; height: 22px;
  display: grid; place-items: center; border-radius: 7px; font-size: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.screenshot { width: 100%; border-radius: 14px; border: 1px solid var(--border); margin-bottom: 16px; box-shadow: var(--shadow-sm); }

.timeline { display: flex; flex-direction: column; gap: 10px; max-height: 380px; overflow: auto; }
.step {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 13px; font-size: 13px;
}
.step .seq { color: var(--muted); font-family: ui-monospace, monospace; min-width: 26px; }
.step .body { flex: 1; min-width: 0; }
.step .act { font-weight: 650; }
.step .thought { color: var(--muted); font-size: 12px; margin-top: 3px; }
.risk { font-size: 10px; padding: 2px 8px; border-radius: 999px; margin-left: 6px; font-weight: 550; }
.risk.low { color: var(--mint-ink); background: var(--mint); }
.risk.medium { color: var(--peach-ink); background: var(--peach); }
.risk.high, .risk.blocked { color: var(--rose-ink); background: var(--rose); }

.detail-actions { display: flex; gap: 10px; margin-top: 16px; }

/* soft scrollbars */
.timeline::-webkit-scrollbar { width: 8px; }
.timeline::-webkit-scrollbar-thumb { background: var(--lav); border-radius: 8px; }

@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

.code-block {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.code-block code {
  flex: 1; min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--text);
  overflow-x: auto; white-space: nowrap;
}
.copy-btn { flex-shrink: 0; padding: 6px 10px; font-size: 12px; }
