/* Agent Hub — clean, light, blue-accent (matches the InGenius mock) */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eff4ff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #ffffff;
  --card: #ffffff;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --radius: 12px;
  font-size: 16px;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
code { background: #f3f4f6; padding: 1px 5px; border-radius: 5px; font-size: .85em; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px); z-index: 20;
}
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.brand .accent { color: var(--blue); font-size: .7rem; font-weight: 700; vertical-align: super; margin-left: 2px; }
.tabs { display: flex; gap: 26px; }
.tab {
  background: none; border: none; padding: 10px 2px; color: var(--ink);
  font-weight: 600; border-bottom: 2px solid transparent; border-radius: 0;
}
.tab.active { border-bottom-color: var(--blue); }
.tab:hover { color: var(--blue); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.pill {
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px;
  font-size: .85rem; color: var(--muted);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: var(--ink); color: #fff; font-weight: 700; font-size: .8rem;
}

/* ---------- layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 40px 32px 90px; }
.kicker { color: var(--blue); font-weight: 700; font-size: .74rem; letter-spacing: .12em; margin-bottom: 8px; }
h1 { font-size: 2.1rem; letter-spacing: -.03em; }
h2 { font-size: 1.15rem; margin: 34px 0 10px; }
h3.step { font-size: .95rem; margin: 26px 0 12px; font-weight: 600; }

/* ---------- sign-in gate ---------- */
.gate {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #fafafa; z-index: 50;
}
.gate-card {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 36px; width: 400px; max-width: 92vw; box-shadow: 0 18px 50px rgba(0,0,0,.08);
}
.gate-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.gate-card p { margin-bottom: 18px; font-size: .9rem; }
.gate-card label { display: block; margin-bottom: 14px; font-weight: 600; font-size: .85rem; }
.gate-error, .modal-error, .composer-error {
  color: var(--bad); font-size: .85rem; margin: 10px 0;
}
.composer-error { max-width: 860px; margin: 10px auto; text-align: center; }

/* ---------- inputs ---------- */
input, textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; margin-top: 6px; background: #fff; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
input:disabled { background: #f6f7f9; color: var(--muted); }
label { font-weight: 600; font-size: .85rem; display: block; margin-bottom: 14px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.row { display: flex; gap: 8px; margin-top: 6px; }
.row input { margin-top: 0; flex: 1; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 10px 20px; font-weight: 600;
}
.btn:hover { border-color: #cfd4dc; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.wide { width: 100%; }
.btn.round { width: 44px; height: 44px; padding: 0; font-size: 1.15rem; }
.btn.danger { color: var(--bad); }
.btn.tiny { padding: 5px 12px; font-size: .8rem; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; font-size: .95rem;
}

/* ---------- workbench layout: sidebar + main ---------- */
.wb-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 32px; align-items: start; }
.wb-side { position: sticky; top: 84px; }
.wb-side-head { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 0 10px; }
.wb-side-head h2 { margin: 0; font-size: .95rem; }
.convo-list { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 240px); overflow-y: auto; }
.convo-item {
  text-align: left; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; padding: 10px 13px; display: flex; flex-direction: column;
  gap: 3px; cursor: pointer; min-width: 0;
}
.convo-item:hover { border-color: #cfd4dc; }
.convo-item.active { border-color: var(--blue); background: var(--blue-soft); }
.convo-item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.convo-snip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.convo-none { padding: 6px 2px; }
.wb-main { min-width: 0; }
.convo-head { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 12px; flex-wrap: wrap; }
#backToList { display: none; }
.convo-turns { padding: 4px 2px 14px; max-height: calc(100vh - 330px); overflow-y: auto; }
#convoScreen .reply-row { margin-top: 6px; }

/* ---------- workbench ---------- */
.hero { text-align: center; margin: 46px 0 30px; }
.hero h1 { font-size: 2.6rem; }
.hero .kicker { margin-bottom: 10px; }
.composer {
  max-width: 860px; margin: 0 auto; border: 1px solid var(--line);
  border-radius: 18px; box-shadow: 0 14px 40px rgba(0,0,0,.06); background: #fff;
  padding: 18px 18px 12px;
}
.composer textarea { border: none; box-shadow: none; resize: vertical; padding: 4px; margin: 0; }
.composer textarea:focus { box-shadow: none; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.composer-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.routing-select {
  width: auto; margin: 0; border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: .88rem;
}
.hub-agents-header { display: flex; justify-content: space-between; align-items: end; max-width: 860px; margin: 40px auto 10px; }
.hub-agents-header h2 { margin: 0; font-size: 1rem; }
.hub-agents { max-width: 860px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.hub-agent {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; background: #fff;
}
.hub-agent.is-off { opacity: .62; }
.hub-agent .dot { margin-left: 0; }
.hub-agent-body { flex: 1; min-width: 0; }
.hub-agent-desc {
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow-wrap: anywhere;
}
.hub-agent button { flex: none; }
.runs-header { display: flex; justify-content: space-between; align-items: end; max-width: 980px; margin: 56px auto 8px; }
.runs-header h2 { margin: 0; }
.runs-list { max-width: 980px; margin: 0 auto; border-top: 1px solid var(--line); }
.empty-row {
  max-width: 980px; margin: 0 auto; display: flex; gap: 14px; align-items: center;
  padding: 26px 6px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.spark { border: 1px solid var(--line); border-radius: 10px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; }
.spark.big { width: 46px; height: 46px; font-size: 1.2rem; margin-bottom: 12px; }

.run-card { border-bottom: 1px solid var(--line); padding: 18px 6px; }
.run-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.run-agent { font-weight: 700; }
.run-time { color: var(--muted); font-size: .8rem; margin-left: auto; }
.status {
  font-size: .74rem; font-weight: 700; border-radius: 999px; padding: 3px 10px;
  text-transform: uppercase; letter-spacing: .04em;
}
.status.queued  { background: #f3f4f6; color: var(--muted); }
.status.running { background: var(--blue-soft); color: var(--blue); }
.status.done    { background: #ecfdf3; color: var(--ok); }
.status.error   { background: #fef2f2; color: var(--bad); }
.routed-tag { font-size: .74rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 999px; padding: 3px 10px; }
.run-input { margin-top: 8px; font-size: .92rem; }
.run-output {
  margin-top: 10px; background: #fafbfc; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem;
  max-height: 340px; overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.run-error { margin-top: 10px; color: var(--bad); font-size: .88rem; }
.cursor-blink::after { content: "▋"; animation: blink 1s step-end infinite; color: var(--blue); }
@keyframes blink { 50% { opacity: 0; } }
.turn-user { margin-top: 14px; font-size: .92rem; overflow-wrap: anywhere; }
.turn-who {
  display: inline-block; font-size: .72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin-right: 8px;
}
.reply-row { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.reply-row .reply-input {
  flex: 1; margin-top: 0; border-radius: 999px; padding: 9px 16px; font-size: .9rem;
}
.btn.round.small { width: 38px; height: 38px; font-size: 1rem; flex: none; }

/* ---------- my agents ---------- */
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 22px; }
.notice {
  display: flex; gap: 14px; align-items: center; background: #f8fafc;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 26px;
}
.notice-icon {
  background: var(--blue-soft); color: var(--blue); width: 34px; height: 34px;
  border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.agents-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.agent-card { border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: #fff; }
.agent-top { display: flex; align-items: center; gap: 8px; }
.agent-name { font-weight: 700; }
.agent-version { color: var(--muted); font-size: .78rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-left: auto; flex: none; }
.dot.on { background: var(--ok); } .dot.off { background: #d1d5db; } .dot.sus { background: var(--bad); }
.agent-desc { margin: 8px 0 10px; font-size: .88rem; color: #374151; min-height: 2.2em; }
.agent-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { font-size: .74rem; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; color: var(--muted); }
.chip.everyone { color: var(--blue); border-color: #bfd3fb; background: var(--blue-soft); }
.agent-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-card {
  border: 1px solid var(--line); border-radius: 16px; text-align: center;
  padding: 56px 20px; max-width: 940px; margin: 0 auto;
}
.empty-card h3 { margin-bottom: 6px; }
.empty-card p { margin-bottom: 18px; }

/* ---------- admin tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: none; }
td.clip { max-width: 340px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,17,21,.45); z-index: 40;
  display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 18px; width: 900px; max-width: 100%;
  padding: 30px 34px 26px; box-shadow: 0 30px 80px rgba(0,0,0,.25); margin-bottom: 6vh;
}
.modal-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 4px; }
.modal-head h1 { font-size: 1.6rem; }
.transport-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tcard {
  display: flex; gap: 12px; align-items: center; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #fff;
}
.tcard.selected { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 0 0 1px var(--blue); }
.tcard-icon { font-size: 1.1rem; }
.tcard-body { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
.contract-note { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.success-banner {
  background: #ecfdf3; color: #166534; border: 1px solid #bbf7d0;
  border-radius: 10px; padding: 13px 16px; margin-bottom: 16px;
}
.success-steps { margin: 0 0 12px 20px; font-size: .9rem; }
.success-steps li { margin-bottom: 6px; }
.codeblock {
  background: #0f1115; color: #d7e0ea; border-radius: 10px; padding: 13px 15px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem;
  overflow-x: auto; white-space: pre; margin: 10px 0 14px; cursor: copy;
}

#hubAgentsCount { white-space: nowrap; flex: none; margin-left: 12px; }

@media (max-width: 900px) {
  .wb-layout { grid-template-columns: 1fr; gap: 20px; }
  .wb-side { position: static; }
  .wb-layout.convo-open .wb-side { display: none; }
  #backToList { display: inline-block; }
  .convo-turns { max-height: none; }
  .hero { margin-top: 16px; }
  .hero h1 { font-size: 2rem; }
}

@media (max-width: 760px) {
  .topbar { padding: 12px 16px; gap: 10px; }
  .tabs { gap: 16px; }
  .tab { font-size: .9rem; }
  .pill { display: none; }
  .brand { font-size: 1rem; }
  main { padding: 24px 16px 70px; }
  .hero h1 { font-size: 1.8rem; }
  .grid2, .transport-cards { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
}
