:root {
  --bg: #060a12;
  --bg-2: #0a101c;
  --panel: #0c1322;
  --panel-2: #0f1829;
  --line: rgba(122, 162, 230, 0.10);
  --line-2: rgba(122, 162, 230, 0.18);
  --text: #d4deee;
  --muted: #7d8ba3;
  --dim: #4f5c73;
  --teal: #2dd4bf;
  --teal-soft: rgba(45, 212, 191, 0.14);
  --violet: #8b7cf6;
  --violet-soft: rgba(139, 124, 246, 0.14);
  --orange: #f05a28;
  --orange-soft: rgba(240, 90, 40, 0.14);
  --red: #f0506e;
  --green: #34d399;
  --amber: #f5b544;
  --done: #5b6780;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  --r: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
body.app {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(45, 212, 191, 0.05), transparent 60%),
    var(--bg);
  min-height: 100vh;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 10, 18, 0.85);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { display: block; filter: drop-shadow(0 0 6px rgba(240, 90, 40, 0.35)); }
.brand-title { font-weight: 650; letter-spacing: 0.14em; font-size: 12.5px; white-space: nowrap; }
.brand-title .sep { color: var(--orange); margin: 0 2px; }
.brand-sub { color: var(--muted); font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; }
.top-stats { display: flex; gap: 8px; flex: 1; justify-content: center; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-2); font-size: 11.5px;
}
.chip-k { color: var(--muted); }
.chip-v { color: var(--text); font-weight: 600; }
.chip-sources:empty { display: none; }
.src { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.src + .src { margin-left: 8px; }
.src b { color: var(--text); font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.dot-run { background: var(--teal); box-shadow: 0 0 8px var(--teal); }
.dot-idle { background: var(--violet); }
.dot-done { background: var(--done); }
.dot-off { background: var(--dim); }
.top-right { display: flex; align-items: center; gap: 14px; }
.clock { text-align: right; }
.clock-time { font-size: 17px; font-weight: 600; letter-spacing: 0.04em; }
.clock-date { color: var(--muted); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; }
.conn {
  display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.conn[data-state="live"] { color: var(--teal); border-color: rgba(45, 212, 191, 0.3); }
.conn[data-state="live"] .conn-dot { background: var(--teal); animation: pulse 1.6s ease-in-out infinite; }
.conn[data-state="down"] { color: var(--orange); border-color: rgba(240, 90, 40, 0.35); }
.conn[data-state="down"] .conn-dot { background: var(--orange); }
.btn-ghost {
  background: transparent; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 6px 11px; color: var(--muted); cursor: pointer; font-size: 12px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.55); } 50% { box-shadow: 0 0 0 5px rgba(45, 212, 191, 0); } }

/* ---------- grid ---------- */
.grid {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr) minmax(300px, 360px);
  grid-template-rows: minmax(500px, 58vh) auto auto auto;
  grid-template-areas:
    "agents graph vitals"
    "sched  sched stream"
    "hosta  hosta stream"
    "telem  telem audit";
  gap: 12px;
  padding: 12px 18px 18px;
}
.p-agents { grid-area: agents; }
.p-graph { grid-area: graph; }
.p-vitals { grid-area: vitals; }
.p-sched { grid-area: sched; }
.p-stream { grid-area: stream; }
.p-telem { grid-area: telem; }
.p-hosta { grid-area: hosta; }
.p-audit { grid-area: audit; }

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--r);
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  position: relative;
  overflow: hidden;
}
.panel::before {
  content: ""; position: absolute; left: 12px; right: 12px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(45, 212, 191, 0.35), transparent);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px 9px; border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0; font-size: 10.5px; font-weight: 650; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.panel-head h2::before { content: ""; width: 5px; height: 5px; background: var(--teal); border-radius: 1px; box-shadow: 0 0 6px var(--teal); }
.panel-meta { color: var(--dim); font-size: 11px; }
.sub-head {
  display: flex; justify-content: space-between; padding: 10px 14px 6px;
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted);
}
.sub-head .mono { letter-spacing: 0; text-transform: none; color: var(--dim); }

/* ---------- agents ---------- */
.agent-list { overflow-y: auto; padding: 6px; flex: 1; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.ag {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center;
  padding: 9px 9px 10px; border-radius: 8px; border: 1px solid transparent;
  transition: background 0.3s, border-color 0.3s;
}
.ag + .ag { margin-top: 2px; }
.ag:hover { background: rgba(122, 162, 230, 0.04); border-color: var(--line); }
.ag.is-flash { background: rgba(240, 90, 40, 0.06); border-color: rgba(240, 90, 40, 0.25); }
.ag .dot { margin-top: 1px; }
.ag-title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-title .kind { color: var(--dim); font-weight: 400; font-size: 11px; margin-left: 6px; }
.ag-right { text-align: right; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.ag-sub {
  grid-column: 2 / 4; display: flex; gap: 8px; align-items: center; min-width: 0;
  font-size: 11.5px; color: var(--muted);
}
.ag-act { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ag-act .tool { color: var(--teal); }
.ag-act .tgt { color: var(--text); opacity: 0.8; }
.ag-tok { margin-left: auto; white-space: nowrap; color: var(--dim); font-size: 11px; }
.ag-bar { grid-column: 2 / 4; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.ag-bar i { display: block; height: 100%; background: var(--teal); box-shadow: 0 0 8px var(--teal); transition: width 1s linear; }
.ag[data-status="idle"] .ag-bar i { background: var(--violet); box-shadow: none; }
.ag[data-status="done"] { opacity: 0.55; }
.ag[data-status="done"] .ag-bar i { background: var(--done); box-shadow: none; }
.st { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; }
.st-running { color: var(--teal); background: var(--teal-soft); }
.st-idle { color: var(--violet); background: var(--violet-soft); }
.st-done { color: var(--muted); background: rgba(122, 162, 230, 0.06); }
.ag-group { padding: 10px 9px 4px; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim); }
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 36px 14px; text-align: center; color: var(--muted);
}
.empty-ring {
  width: 44px; height: 44px; border-radius: 50%; border: 1px dashed var(--line-2); position: relative;
  animation: spin 14s linear infinite;
}
.empty-ring::after { content: ""; position: absolute; top: -3px; left: 50%; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 8px var(--teal); }
.empty b { color: var(--text); font-weight: 550; }
.empty small { color: var(--dim); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- graph ---------- */
.graph-wrap { position: relative; flex: 1; min-height: 0; }
#graph { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.graph-empty {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  color: var(--muted); font-size: 12px; letter-spacing: 0.06em; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(6, 10, 18, 0.6);
}
.legend { display: flex; gap: 12px; font-size: 10.5px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.lg-run { background: var(--teal); box-shadow: 0 0 6px var(--teal); }
.lg-idle { background: var(--violet); }
.lg-done { background: var(--done); }
.lg-pulse { background: var(--orange); box-shadow: 0 0 6px var(--orange); }
.tip {
  position: absolute; pointer-events: none; z-index: 3; max-width: 280px;
  background: rgba(8, 13, 23, 0.96); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 10px; font-size: 11.5px; color: var(--text); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.tip .t1 { font-weight: 600; margin-bottom: 3px; }
.tip .t2 { color: var(--muted); }

/* ---------- vitals ---------- */
.vitals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px 0; }
.vt, .tm {
  background: rgba(6, 10, 18, 0.45); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px 6px; position: relative; min-width: 0;
}
.vt-k, .tm-k { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.vt-v, .tm-v { font-size: 19px; font-weight: 600; margin-top: 2px; white-space: nowrap; }
.vt-v small, .tm-v small { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.spark { display: block; width: 100%; height: 30px; margin-top: 4px; }
.cores { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; padding: 0 12px; }
.core {
  height: 22px; border-radius: 4px; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font: 10px var(--mono); color: rgba(212, 222, 238, 0.75);
  transition: background-color 0.8s ease;
}
.envelope { display: block; width: calc(100% - 24px); height: 92px; margin: 0 12px 12px; }

/* ---------- schedule ---------- */
.sched-wrap { overflow-x: auto; }
.sched { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.sched th {
  text-align: left; font-weight: 500; color: var(--dim); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 9px 14px 7px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.sched td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.sched tr:last-child td { border-bottom: 0; }
.sched tbody tr { transition: background 0.3s; }
.sched tbody tr:hover { background: rgba(122, 162, 230, 0.03); }
.sched .num { text-align: right; }
.au-name { font-weight: 550; }
.au-id { color: var(--dim); font-size: 11px; margin-left: 6px; }
.au-where { color: var(--muted); font-size: 11px; display: block; margin-top: 1px; }
.au-cron { color: var(--text); }
.au-plan { display: inline-block; margin-left: 6px; font-size: 10px; color: var(--amber); border: 1px solid rgba(245, 181, 68, 0.3); border-radius: 4px; padding: 0 5px; letter-spacing: 0.04em; }
.au-live { display: inline-block; margin-left: 6px; font-size: 10px; color: var(--teal); border: 1px solid rgba(45, 212, 191, 0.3); border-radius: 4px; padding: 0 5px; }
.count { font-size: 14px; font-weight: 600; color: var(--text); }
.count.soon { color: var(--orange); }
.at { color: var(--dim); font-size: 11px; display: block; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 550; border: 1px solid transparent;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-passed { color: var(--green); background: rgba(52, 211, 153, 0.1); border-color: rgba(52, 211, 153, 0.25); }
.pill-failed, .pill-error { color: var(--red); background: rgba(240, 80, 110, 0.1); border-color: rgba(240, 80, 110, 0.25); }
.pill-running { color: var(--teal); background: var(--teal-soft); border-color: rgba(45, 212, 191, 0.3); }
.pill-running::before { animation: blink 1s steps(2) infinite; }
.pill-cancelled { color: var(--muted); background: rgba(122, 162, 230, 0.06); border-color: var(--line-2); }
.pill-none { color: var(--dim); background: transparent; border-color: var(--line); }
.pill-none::before { background: transparent; border: 1px solid var(--dim); }
@keyframes blink { 50% { opacity: 0.2; } }
.hist { display: inline-flex; gap: 2px; align-items: flex-end; height: 16px; }
.hist i { width: 4px; height: 100%; border-radius: 1px; background: var(--line-2); }
.hist i.passed { background: var(--green); opacity: 0.8; }
.hist i.failed, .hist i.error { background: var(--red); }
.hist i.running { background: var(--teal); }
.hist i.cancelled { background: var(--done); height: 60%; }
.find-0 { color: var(--dim); }
.find-n { color: var(--amber); font-weight: 600; }
.find-c { color: var(--red); font-weight: 600; }
.notice { margin: 10px 14px 12px; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(240, 90, 40, 0.3); background: var(--orange-soft); color: #ffb79c; font-size: 12px; }

/* ---------- stream ---------- */
.stream {
  flex: 1; overflow-y: auto; padding: 4px 0; min-height: 260px; max-height: 640px;
  font: 11.5px/1.4 var(--mono); scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.ev {
  display: grid; grid-template-columns: 58px 54px minmax(0, 1fr); gap: 8px; padding: 4px 14px;
  border-left: 2px solid transparent; animation: evIn 0.5s ease-out;
}
.ev:hover { background: rgba(122, 162, 230, 0.03); }
.ev-t { color: var(--dim); }
.ev-k { font-size: 9.5px; letter-spacing: 0.08em; text-align: center; border-radius: 3px; padding: 1px 0; align-self: start; margin-top: 1px; }
.ev-b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.ev-b .who { color: var(--text); opacity: 0.85; }
.ev-b .tool { color: var(--teal); }
.ev-b .ms { color: var(--dim); }
.k-tool { color: var(--teal); background: var(--teal-soft); }
.k-done { color: var(--muted); background: rgba(122, 162, 230, 0.06); }
.k-err { color: var(--red); background: rgba(240, 80, 110, 0.12); }
.k-reply { color: var(--violet); background: var(--violet-soft); }
.k-prompt { color: var(--orange); background: var(--orange-soft); }
.k-start { color: var(--orange); background: var(--orange-soft); }
.ev.is-err { border-left-color: var(--red); }
.ev.is-start { border-left-color: var(--orange); }
@keyframes evIn { from { opacity: 0; transform: translateY(-4px); background: rgba(45, 212, 191, 0.08); } to { opacity: 1; transform: none; } }

/* ---------- telemetry ---------- */
.telem { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding: 10px 12px 12px; }
.tm-s { color: var(--dim); font-size: 11px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm .spark { height: 40px; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .grid {
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
    grid-template-rows: minmax(480px, 56vh) auto auto auto auto;
    grid-template-areas:
      "agents graph"
      "vitals sched"
      "vitals stream"
      "hosta  audit"
      "telem  telem";
  }
  .telem { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 14px; position: static; }
  .brand-title { font-size: 11.5px; letter-spacing: 0.1em; }
  .brand-sub { display: none; }
  .top-stats { order: 3; flex-basis: 100%; justify-content: flex-start; }
  .top-right { margin-left: auto; gap: 8px; }
  .clock-time { font-size: 15px; }
  .clock-date { display: none; }
  .conn span:last-child { display: none; }
  .grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "agents" "graph" "hosta" "sched" "stream" "audit" "vitals" "telem";
    padding: 10px 12px 16px;
    gap: 10px;
  }
  .p-agents { max-height: 420px; }
  .p-graph .legend { display: none; }
  .p-graph { height: 360px; }
  .stream { max-height: 360px; min-height: 200px; }
  .telem { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cores { grid-template-columns: repeat(8, 1fr); }
  .sched th:nth-child(2), .sched td:nth-child(2), .sched th:nth-child(5), .sched td:nth-child(5), .sched th:nth-child(7), .sched td:nth-child(7) { display: none; }
  .modal { max-width: none; }
  .modal-back { padding: 12px; align-items: flex-end; }
  .sched td, .sched th { padding: 9px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- login ---------- */
body.login {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px;
  background:
    radial-gradient(800px 400px at 50% 0%, rgba(45, 212, 191, 0.07), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 360px; padding: 28px 24px 24px;
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--panel);
}
.login-card .brand { margin-bottom: 22px; }
.login-card label { display: block; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.login-card input {
  width: 100%; padding: 11px 12px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--text); font: 14px var(--mono); outline: none;
}
.login-card input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.btn-primary {
  margin-top: 14px; width: 100%; padding: 11px; border-radius: 8px; border: 0; cursor: pointer;
  background: var(--orange); color: #fff; font-weight: 600; letter-spacing: 0.02em;
}
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.login-err { min-height: 18px; margin-top: 10px; color: #ff9f7f; font-size: 12.5px; }

/* ---------- login 2FA ---------- */
.login-note { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
.qr { background: #fff; border-radius: 10px; padding: 8px; width: 196px; height: 196px; margin: 0 auto 10px; }
.qr svg { width: 100%; height: 100%; display: block; }
.secret { text-align: center; font-size: 12px; color: var(--text); letter-spacing: 0.06em; margin-bottom: 16px; word-break: break-all; }
#stepCode input { letter-spacing: 0.4em; text-align: center; font-size: 18px; }

/* ---------- controls ---------- */
.btn-act {
  background: transparent; border: 1px solid var(--line-2); border-radius: 6px; color: var(--text);
  padding: 4px 9px; font-size: 11.5px; cursor: pointer; white-space: nowrap; line-height: 1.3;
}
.btn-act:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.btn-act:disabled { opacity: 0.4; cursor: default; }
.btn-act-primary { border-color: rgba(240, 90, 40, 0.5); color: #ffb79c; }
.btn-act-primary:hover:not(:disabled) { border-color: var(--orange); color: #fff; background: var(--orange-soft); }
.btn-act-danger { border-color: rgba(240, 80, 110, 0.4); color: #ff9fb1; }
.btn-act-danger:hover:not(:disabled) { border-color: var(--red); color: #fff; background: rgba(240, 80, 110, 0.12); }
.acts { display: inline-flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.sched .act-col { text-align: right; }
.sched td.act-col { white-space: nowrap; }
.au-state { display: block; font-size: 11px; margin-top: 2px; }
.au-paused { color: var(--amber); }
.au-unknown { color: var(--orange); }
.au-running { color: var(--teal); }
.ag-stop { margin-left: 6px; padding: 1px 7px; font-size: 10.5px; }

.hosta { padding: 6px 8px 10px; max-height: 340px; overflow-y: auto; }
.ha {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; align-items: center;
  padding: 9px 8px; border-bottom: 1px solid var(--line);
}
.ha:last-child { border-bottom: 0; }
.ha-title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ha-sub { color: var(--muted); font-size: 11.5px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ha .acts { grid-row: 1 / 3; grid-column: 2; }

.audit { padding: 4px 0 8px; max-height: 340px; overflow-y: auto; font-size: 12px; }
.au-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 8px; padding: 6px 14px; border-bottom: 1px solid var(--line); align-items: baseline; }
.au-row:last-child { border-bottom: 0; }
.au-row .t { color: var(--dim); font-family: var(--mono); font-size: 11px; }
.au-row .w { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-row .w b { font-weight: 550; }
.au-row .w span { color: var(--muted); }
.au-row .r-ok { color: var(--green); font-size: 11px; }
.au-row .r-err { color: var(--red); font-size: 11px; }

.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(3, 6, 12, 0.72); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  width: 100%; max-width: 460px; max-height: 90vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal.wide { max-width: 980px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.modal-x { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; padding: 0 4px; }
.modal-body { padding: 14px 16px; overflow-y: auto; color: var(--text); font-size: 13px; }
.modal-body p { margin: 0 0 10px; color: var(--muted); }
.modal-body p b { color: var(--text); font-weight: 600; }
.modal-body label { display: block; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 10px 0 6px; }
.modal-body textarea, .modal-body select, .modal-body input {
  width: 100%; padding: 10px 11px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--text); font: 13px var(--sans); outline: none;
}
.modal-body textarea { min-height: 160px; resize: vertical; font-family: var(--sans); line-height: 1.5; }
.modal-body input.code { font: 20px var(--mono); letter-spacing: 0.4em; text-align: center; }
.modal-body textarea:focus, .modal-body select:focus, .modal-body input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.modal-err { min-height: 0; padding: 0 16px; color: #ff9f7f; font-size: 12.5px; }
.modal-err:not(:empty) { padding-bottom: 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.modal-foot .btn-primary { width: auto; margin: 0; padding: 8px 16px; }
.modal-foot .btn-danger { background: var(--red); }
.logbox {
  margin: 0; padding: 10px 12px; background: #050810; border: 1px solid var(--line); border-radius: 8px;
  font: 11.5px/1.5 var(--mono); color: #b8c4d8; white-space: pre-wrap; word-break: break-word;
  min-height: 300px; max-height: 62vh; overflow-y: auto;
}
.log-meta { display: flex; justify-content: space-between; color: var(--dim); font-size: 11px; margin-bottom: 8px; }
.hint { color: var(--dim); font-size: 11.5px; margin-top: 6px; }
.st-err { color: var(--red); background: rgba(240, 80, 110, 0.12); }

/* ---------- agent drawer & tooltip ---------- */
.tip-float { position: fixed; z-index: 40; }
.tip .t3 { color: var(--teal); margin-top: 3px; }
.tip .t4 { color: var(--dim); margin-top: 3px; font-family: var(--mono); font-size: 11px; }
.ag { cursor: pointer; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: 440px; max-width: 100vw;
  background: var(--panel); border-left: 1px solid var(--line-2); box-shadow: -20px 0 50px rgba(0, 0, 0, 0.45);
  display: flex; flex-direction: column; animation: drawerIn 0.25s ease-out;
}
@keyframes drawerIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 16px 16px 8px; }
.drawer-kicker { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.drawer-head h3 { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.35; }
.drawer-meta { padding: 0 16px 10px; display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 11.5px; border-bottom: 1px solid var(--line); }
.drawer-meta b { color: var(--text); font-weight: 500; }
.drawer-acts { display: flex; gap: 6px; padding: 10px 16px 0; }
.drawer-acts:empty { display: none; }
.drawer-body { flex: 1; overflow-y: auto; padding-bottom: 16px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.steps { list-style: none; margin: 0; padding: 0 14px; }
.steps li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; padding: 6px 2px; font-size: 12.5px; align-items: start; }
.steps li .ic { width: 14px; height: 14px; border-radius: 50%; margin-top: 2px; border: 1.5px solid var(--dim); position: relative; }
.steps li.completed { color: var(--muted); }
.steps li.completed .ic { border-color: var(--teal); background: var(--teal-soft); }
.steps li.completed .ic::after {
  content: ""; position: absolute; left: 4px; top: 1.5px; width: 3px; height: 6px;
  border: solid var(--teal); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}
.steps li.in_progress { color: var(--text); font-weight: 550; }
.steps li.in_progress .ic { border-color: var(--orange); }
.steps li.in_progress .ic::after {
  content: ""; position: absolute; inset: 2.5px; border-radius: 50%; background: var(--orange);
  box-shadow: 0 0 8px var(--orange); animation: blink 1.2s ease-in-out infinite;
}
.steps-empty { padding: 4px 16px; color: var(--dim); font-size: 12px; }
.last-text { margin: 0 16px; padding: 9px 11px; border-radius: 8px; background: rgba(6, 10, 18, 0.5); border: 1px solid var(--line); color: var(--text); font-size: 12.5px; line-height: 1.5; }
.timeline { padding: 0 8px; font: 11.5px/1.4 var(--mono); }
.tl { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 8px; padding: 4px 8px; border-left: 2px solid transparent; }
.tl:hover { background: rgba(122, 162, 230, 0.03); }
.tl .t { color: var(--dim); }
.tl .w { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.tl .w b { color: var(--teal); font-weight: 400; }
.tl .d { color: var(--dim); white-space: nowrap; }
.tl.err { border-left-color: var(--red); }
.tl.err .d { color: var(--red); }
.tl.live .d { color: var(--teal); }
@media (max-width: 820px) { .drawer { width: 100vw; } }
