:root {
  color-scheme: dark;
  --bg: #0b0c0d;
  --surface: #121416;
  --surface-raised: #181b1e;
  --line: #292d31;
  --line-strong: #3b4146;
  --text: #f3f4ef;
  --muted: #8f969c;
  --green: #b7f35b;
  --green-soft: rgba(183, 243, 91, .12);
  --amber: #ffc857;
  --red: #ff786f;
  --blue: #7fb2ff;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 88% -10%, rgba(183, 243, 91, .09), transparent 28rem),
    var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.shell { width: min(1480px, calc(100% - 44px)); margin: 0 auto; padding-bottom: 48px; }
.topbar { height: 92px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--green); border-radius: 12px; color: var(--green); font-weight: 800; font-size: 19px; box-shadow: inset 0 0 20px rgba(183, 243, 91, .08); }
.eyebrow { color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
h1 { margin: 4px 0 0; font-size: 18px; letter-spacing: -.02em; }
.live-state { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.live-state.online { color: var(--green); }
.live-state.offline { color: var(--red); }
.live-state.pending { color: var(--amber); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 12%, transparent); }

main { padding-top: 26px; }
.hero { min-height: 146px; display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 28px 32px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(125deg, rgba(183, 243, 91, .07), transparent 42%), var(--surface); }
.hero h2 { margin: 9px 0 7px; max-width: 900px; font-size: clamp(23px, 3vw, 36px); line-height: 1.12; letter-spacing: -.045em; }
.hero p { max-width: 840px; margin: 0; color: var(--muted); font-size: 13px; }
.hero-status { flex: 0 0 auto; padding: 8px 13px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 12px 0; }
.stats article { min-height: 82px; padding: 17px 19px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.stats span { color: var(--muted); font-size: 11px; }
.stats strong { display: block; margin-top: 7px; font-size: 24px; line-height: 1; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(330px, .72fr); min-height: 600px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.list-panel { min-width: 0; border-right: 1px solid var(--line); }
.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 142px 42px; gap: 9px; padding: 15px; border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 9px; min-width: 0; height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--muted); }
.search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.search input { width: 100%; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); }
.search input::placeholder { color: #676d72; }
select, .icon-button { height: 42px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); }
select { padding: 0 11px; outline: none; }
.icon-button { width: 42px; font-size: 18px; }
.icon-button:hover { color: var(--green); border-color: var(--green); }
.icon-button.loading { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.list-heading { display: flex; justify-content: space-between; gap: 16px; padding: 12px 17px; color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); }
.task-list { max-height: 630px; overflow: auto; }
.task-row { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 106px 112px; align-items: center; gap: 16px; padding: 15px 17px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; text-align: left; transition: background .15s ease, box-shadow .15s ease; }
.task-row:hover { background: rgba(255,255,255,.025); }
.task-row.viewing { background: rgba(127, 178, 255, .055); box-shadow: inset 3px 0 var(--blue); }
.task-row.selected { background: var(--green-soft); box-shadow: inset 3px 0 var(--green); }
.task-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; font-weight: 650; }
.task-title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-mark { flex: 0 0 auto; padding: 2px 6px; border-radius: 4px; background: var(--green); color: #172006; font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.task-sub { margin-top: 6px; overflow: hidden; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.task-time { color: var(--muted); font-size: 11px; text-align: right; }

.status { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 5px 8px; border-radius: 999px; background: #22262a; color: #b8bec3; font-size: 10px; font-weight: 750; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.running { background: var(--green-soft); color: var(--green); }
.status.waiting_input, .status.waiting_connector, .status.waiting_confirmation { background: rgba(255, 200, 87, .11); color: var(--amber); }
.status.failed { background: rgba(255, 120, 111, .11); color: var(--red); }
.status.succeeded { background: rgba(127, 178, 255, .11); color: var(--blue); }
.status.archived { opacity: .58; }

.detail-panel { min-width: 0; padding: 24px; background: var(--surface-raised); }
.empty-detail { height: 100%; min-height: 400px; display: grid; align-content: center; justify-items: center; text-align: center; color: var(--muted); }
.empty-symbol { color: var(--line-strong); font-size: 46px; }
.empty-detail h3 { margin: 13px 0 5px; color: var(--text); font-size: 16px; }
.empty-detail p { max-width: 260px; margin: 0; font-size: 12px; line-height: 1.6; }
.detail-kicker { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.detail-panel h3 { margin: 10px 0 12px; font-size: 23px; line-height: 1.2; letter-spacing: -.035em; }
.detail-status-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 19px; border-bottom: 1px solid var(--line); }
.detail-grid { display: grid; gap: 15px; margin: 21px 0; }
.detail-field span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.detail-field code, .detail-field p { display: block; margin: 0; overflow-wrap: anywhere; color: #d5d8d9; font-size: 11px; line-height: 1.55; }
.primary-button { width: 100%; min-height: 44px; margin-top: 8px; border: 1px solid var(--green); border-radius: 10px; background: var(--green); color: #151b09; font-weight: 850; }
.primary-button:hover { filter: brightness(1.06); }
.primary-button:disabled { cursor: default; opacity: .42; filter: none; }
.detail-note { margin-top: 13px; color: var(--muted); font-size: 10px; line-height: 1.55; }

.scope-note { margin: 12px 3px 0; color: #697076; font-size: 10px; }
.transport-note { margin: 6px 3px 0; color: var(--amber); font-size: 10px; }
.transport-note.ready { color: var(--green); }
.empty-list { padding: 60px 20px; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 360px; padding: 12px 15px; border: 1px solid var(--line-strong); border-radius: 10px; background: #22262a; color: var(--text); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s ease; box-shadow: 0 15px 45px rgba(0,0,0,.35); font-size: 12px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--red); }

@media (max-width: 900px) {
  .shell { width: min(100% - 24px, 740px); }
  .topbar { height: 76px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .workspace { grid-template-columns: 1fr; }
  .list-panel { border-right: 0; }
  .detail-panel { border-top: 1px solid var(--line); }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .toolbar { grid-template-columns: 1fr 42px; }
  .toolbar select { grid-row: 2; grid-column: 1 / -1; }
  .task-row { grid-template-columns: minmax(0, 1fr) auto; }
  .task-time { display: none; }
}
