/* Command Center: dark only, no animations, system fonts. */
:root {
  --bg: #0E0F12;
  --card: #17191E;
  --card-hi: #1E2128;
  --border: #262A31;
  --text: #E8EAED;
  --text-2: #9AA0A6;
  --accent: #4C8DFF;
  --idle: #6B7280;
  --working: #4C8DFF;
  --needs: #F5B83D;
  --done: #34C77B;
  --error: #F25C54;
  --paused: #6B7280;
  --radius: 12px;
  --gap: 12px;
  --tabbar: 64px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; transition: none !important; animation: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 400 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 500; margin: 0 0 16px; }
h2 { font-size: 16px; font-weight: 500; margin: 24px 0 12px; }
h3 { font-size: 14px; font-weight: 500; margin: 16px 0 8px; color: var(--text-2); }
p { margin: 0 0 12px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
code, pre, textarea.mono { font-family: ui-monospace, Consolas, "Cascadia Mono", monospace; font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.i { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.i.sm { width: 16px; height: 16px; }
.i.lg { width: 24px; height: 24px; }
.muted { color: var(--text-2); }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack > * + * { margin-top: 12px; }

/* ---------- layout ---------- */
.app { min-height: 100vh; }
main { padding: 16px 16px calc(var(--tabbar) + 24px + env(safe-area-inset-bottom)); max-width: 1200px; margin: 0 auto; }
.side { display: none; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--border);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-2); font-size: 12px; min-height: 44px; text-decoration: none;
}
.tabs a.active { color: var(--accent); }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 232px 1fr; }
  .tabs { display: none; }
  .side {
    display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 16px 12px; background: var(--card); border-right: 1px solid var(--border);
  }
  .side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-size: 16px; font-weight: 500; }
  .side .brand img { width: 28px; height: 28px; border-radius: 6px; }
  .side a {
    display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px; border-radius: 8px;
    color: var(--text); text-decoration: none;
  }
  .side a:hover { background: var(--card-hi); }
  .side a.active { color: var(--accent); background: var(--card-hi); }
  .side .sep { height: 1px; background: var(--border); margin: 8px 4px; }
  main { padding: 24px 32px 48px; width: 100%; }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card-hi); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #3a3f48; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--error); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.icon { padding: 0; width: 44px; }
.btn.small.icon { width: 36px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.block { width: 100%; }

label { display: block; color: var(--text-2); margin: 12px 0 6px; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); min-height: 44px; margin: 0; cursor: pointer; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.big { min-height: 320px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { min-height: 36px; min-width: 56px; padding: 0 12px; border: 0; background: transparent; color: var(--text-2); font: inherit; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card.link { cursor: pointer; }
.card.link:hover { background: var(--card-hi); }
.list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list > * { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 16px; border-top: 1px solid var(--border); color: var(--text); text-decoration: none; }
.list > *:first-child { border-top: 0; }
.list > a:hover { background: var(--card-hi); text-decoration: none; }
.empty { color: var(--text-2); padding: 24px 0; text-align: center; }

/* ---------- status ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); flex: none; }
.s-idle .dot { background: var(--idle); }
.s-working .dot { background: var(--working); }
.s-needs_input .dot { background: var(--needs); }
.s-done .dot { background: var(--done); }
.s-error .dot { background: var(--error); }
.s-paused .dot, .s-stopped .dot { background: var(--paused); }

/* ---------- dashboard ---------- */
.summary { color: var(--text-2); margin: -8px 0 16px; }
.summary b { color: var(--text); font-weight: 500; }
.pins { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; }
.pin-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 18px; background: var(--card); border: 1px solid var(--border); color: var(--text); white-space: nowrap; max-width: 260px; }
.pin-chip span { overflow: hidden; text-overflow: ellipsis; }
.notice { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--border); margin-bottom: 16px; }
.notice.warn { border-color: #5a4a22; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1250px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.bot { display: flex; flex-direction: column; gap: 8px; min-height: 150px; cursor: pointer; }
.bot:hover { background: var(--card-hi); }
.bot.s-needs_input { border-color: #5a4a22; }
.bot.s-error { border-color: #5a2a28; }
.bot-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bot-head .name { font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot .progress { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 20px; }
.bot .result { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot .actions { display: flex; gap: 6px; margin-top: auto; }
.bot .actions .btn { flex: 1; min-width: 0; padding: 0 6px; gap: 4px; }
.bot .reply { font-size: 13px; color: var(--needs); }

.bot-head .chat-link { margin-left: auto; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin-top: -6px; margin-right: -6px; border-radius: 8px; color: var(--accent); }
.bot-head .chat-link:hover { background: var(--card-hi); }

/* ---------- quick start overview ---------- */
.qs-tabs { display: flex; width: 100%; margin-bottom: 12px; }
.qs-tabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; min-width: 0; padding: 0 4px; white-space: nowrap; font-size: 13px; }
@media (max-width: 420px) { .qs-tabs .i { display: none; } }
.qs-tabs .badge { background: transparent; }
.qs-item { display: flex; flex-direction: column; gap: 8px; }
.qs-item.s-needs_input { border-color: #5a4a22; }
.qs-item.s-error { border-color: #5a2a28; }
.qs-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.qs-commands { margin-top: 24px; }
.qs-commands summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; color: var(--text-2); }

/* ---------- chat ---------- */
.chat-msgs { display: flex; flex-direction: column; gap: 10px; padding-bottom: 80px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: #1F3A66; border-bottom-right-radius: 4px; }
.msg.bot-msg { align-self: flex-start; background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.bot-msg .md > :last-child { margin-bottom: 0; }
.msg.perm { align-self: stretch; max-width: none; background: var(--card); border: 1px solid #5a4a22; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left; }
.msg.perm pre.raw { align-self: stretch; }
.msg-time { font-size: 12px; color: var(--text-2); margin-top: 4px; text-align: right; }
.chat-wait { padding: 4px 2px; }
.chat-form {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); z-index: 9;
  display: flex; gap: 8px; align-items: flex-end; padding: 8px 16px; background: var(--bg); border-top: 1px solid var(--border);
}
.chat-form textarea { min-height: 44px; max-height: 200px; resize: none; }
.chat-form .mic-lang { min-width: 40px; padding: 0 8px; min-height: 44px; font-size: 12px; color: var(--text-2); }
.btn.rec { background: var(--error); border-color: var(--error); color: #fff; }
@media (min-width: 900px) { .chat-form { left: 232px; bottom: 0; padding: 12px 32px; } }

/* ---------- activity ---------- */
.act { align-items: flex-start !important; }
.act time { color: var(--text-2); font-size: 13px; width: 48px; flex: none; padding-top: 1px; }
.act .ev { font-weight: 500; }
.act .msg { color: var(--text-2); word-break: break-word; }

/* ---------- analytics ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); margin-bottom: 16px; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.tile .num { font-size: 22px; font-weight: 500; }
.tile .lbl { color: var(--text-2); font-size: 13px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; margin: 8px 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart { width: 100%; overflow: visible; }
.chart text { fill: var(--text-2); font-size: 12px; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .hit:hover + g rect, .chart g.bar:hover rect { opacity: .85; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--card-hi); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; max-width: 240px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-top: 1px solid var(--border); }
th { color: var(--text-2); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- files & markdown ---------- */
.crumbs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; color: var(--text-2); margin-bottom: 12px; }
.md { line-height: 1.6; word-wrap: break-word; }
.md h1 { font-size: 22px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; color: var(--text); }
.md ul, .md ol { padding-left: 22px; margin: 0 0 12px; }
.md pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; }
.md code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.md pre code { background: none; padding: 0; }
.md table { margin: 0 0 12px; display: block; overflow-x: auto; }
.md blockquote { margin: 0 0 12px; padding-left: 12px; border-left: 3px solid var(--border); color: var(--text-2); }
.md img { max-width: 100%; }
.preview-img { max-width: 100%; border-radius: 8px; }
pre.raw { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 0; }

/* ---------- search ---------- */
.search-box { position: relative; margin-bottom: 16px; }
.search-box .i { position: absolute; left: 12px; top: 12px; color: var(--text-2); }
.search-box input { padding-left: 40px; }
.hit-snippet { color: var(--text-2); font-size: 13px; }
.hit-snippet mark { background: none; color: var(--needs); }

/* ---------- forms: bots, rules, workflows ---------- */
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, 44px); gap: 6px; }
.icon-grid button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.icon-grid button.on { border-color: var(--accent); color: var(--accent); }
.perm { display: flex; align-items: center; gap: 12px; min-height: 52px; border-top: 1px solid var(--border); }
.perm:first-child { border-top: 0; }
.step { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px 0; border-top: 1px solid var(--border); }
.step:first-child { border-top: 0; }
@media (min-width: 700px) { .step { grid-template-columns: 180px 1fr auto; align-items: start; } }
.rule { display: grid; gap: 8px; }
@media (min-width: 700px) { .rule .fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; } }
.secret { font-family: ui-monospace, Consolas, monospace; word-break: break-all; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }

/* ---------- misc ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); z-index: 60; background: var(--card-hi); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; max-width: calc(100% - 32px); }
.toast.err { border-color: var(--error); }
@media (min-width: 900px) { .toast { bottom: 24px; } }
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.login .logo { width: 64px; height: 64px; border-radius: 14px; display: block; margin: 0 auto 16px; }
.login h1 { text-align: center; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--card-hi); border: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.head h1 { margin: 0; }
.head .btn-search { display: inline-flex; }
@media (min-width: 900px) { .head .btn-search { display: none; } }
.more-list .i { color: var(--text-2); }
