:root {
  --bg: #0b1220; --panel: #131c2e; --panel2: #1a2438; --line: #263248;
  --text: #e8eef7; --muted: #8a98ad; --accent: #19e3c9; --accent-ink: #062a26;
  --warn: #f5a524; --err: #f2545b; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, "Inter", sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }
h2 { font-size: 18px; margin: 22px 0 10px; }
a { cursor: pointer; }

.brand { display: flex; gap: 10px; align-items: center; }
.brand b { display: block; font-size: 17px; }
.brand small { color: var(--muted); }
.logo { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #0f3d3a, #19e3c9); color: var(--accent-ink); font-weight: 800; }

.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 700; font-size: 15px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 8px 0; }
.error { color: var(--err); min-height: 1.2em; }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, textarea { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; font: inherit; }
input:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* каркас */
.app { display: flex; min-height: 100vh; }
.side { width: 210px; background: #0e1626; border-right: 1px solid var(--line); padding: 18px 14px;
  display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.side nav { display: grid; gap: 4px; }
.side nav a, .bottom a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; }
.side nav a.active { background: var(--panel2); color: var(--accent); }
.side #logout { margin-top: auto; text-align: left; }
main { flex: 1; min-width: 0; padding: 18px 22px 90px; max-width: 1100px; }
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.pill { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 6px 12px;
  display: inline-flex; gap: 8px; align-items: center; font-size: 13px; margin-left: auto; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok, .dot.working { background: var(--accent); }
.dot.waiting { background: var(--warn); }
.dot.error { background: var(--err); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat small { color: var(--muted); font-size: 11px; letter-spacing: .06em; display: block; }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; color: var(--accent); }
.stat span { color: var(--muted); margin-left: 4px; }
.bar { height: 5px; background: var(--panel2); border-radius: 9px; margin-top: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); width: 0; margin: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.director { margin-top: 12px; display: flex; gap: 12px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 12px; border: 1px solid #1d5d55; background: #0f2a2b;
  color: var(--accent); display: grid; place-items: center; font-weight: 800; flex: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.member { display: grid; gap: 6px; }
.member .head { display: flex; gap: 10px; align-items: center; }
.member .status { font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.member .task { color: var(--muted); font-size: 13px; min-height: 2.6em; }
.st-working { color: var(--accent); } .st-waiting { color: var(--warn); } .st-error { color: var(--err); }
.st-idle { color: var(--muted); } .st-queued { color: var(--accent); }
.dot.queued { background: var(--accent); }
.member .give { justify-self: start; padding: 8px 14px; font-size: 14px; }
.assign { display: grid; gap: 10px; margin-bottom: 12px; border-left: 3px solid var(--accent); }
.assign .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.feed { display: grid; gap: 2px; }
.feed div { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.feed time { color: var(--accent); font-variant-numeric: tabular-nums; flex: none; width: 48px; }
.empty { color: var(--muted); padding: 14px 0; }

/* чат */
.chat-view { display: flex; flex-direction: column; height: calc(100vh - 110px); }
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0 12px; }
.msg { max-width: 78%; padding: 10px 13px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.typing { color: var(--muted); }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 140px; }

.mic { padding: 10px 12px; font-size: 17px; }
.mic.on { background: var(--err); color: #fff; border-color: transparent; }
.voice-toggle { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.voice-toggle input { width: auto; }
.voice-note { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.msg .say { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 0 0 6px; font-size: 13px; }
.voice-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.voice-bar .voice-toggle { margin: 0; }
.voice-bar select { width: auto; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; font: inherit; font-size: 13px; }
.call-btn { padding: 7px 12px; font-size: 14px; margin-left: auto; }
.mic { touch-action: none; user-select: none; -webkit-user-select: none; min-width: 52px; }
.msg .voice-player { display: block; width: 230px; max-width: 100%; height: 36px; margin-top: 6px; }
.msg.user.voice { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.msg.voice .heard { font-size: 14px; margin-top: 4px; }
.call { position: fixed; inset: 0; background: rgba(5, 10, 20, .92); z-index: 50; display: grid; place-items: center; padding: 16px; }
.call-box { width: 100%; max-width: 360px; display: grid; gap: 14px; justify-items: center; text-align: center; }
.call-avatar { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; font-size: 40px; font-weight: 800;
  background: linear-gradient(135deg, #0f3d3a, #19e3c9); color: var(--accent-ink); }
.call-status { color: var(--accent); font-size: 18px; min-height: 1.4em; }
.call-level { width: 70%; height: 6px; background: var(--panel2); border-radius: 9px; overflow: hidden; }
.call-level span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s; }
.call-heard { color: var(--muted); font-size: 14px; min-height: 3em; }
.call-end { background: var(--err); color: #fff; width: 100%; }

.kb { display: grid; gap: 10px; }
.kb details { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.kb summary { cursor: pointer; font-weight: 700; display: flex; justify-content: space-between; gap: 10px; }
.kb summary small { color: var(--muted); font-weight: 400; }
.kb .md { color: #cfd8e6; font-size: 14px; margin-top: 10px; }
.kb .md h3 { font-size: 15px; margin: 14px 0 6px; color: var(--text); }
.kb .md ul { margin: 4px 0; padding-left: 18px; }
.kb .md p { margin: 6px 0; }

.badge { background: var(--warn); color: #241600; border-radius: 99px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
.grid-1 { display: grid; gap: 10px; }
.approval { display: grid; gap: 8px; border-left: 3px solid var(--warn); }
.approval .meta { color: var(--muted); font-size: 13px; }
.approval .meta.warn { color: var(--warn); }
.approval details summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.approval .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.approval textarea { min-height: 70px; }
.approval.done { opacity: .6; border-left-color: var(--accent); }
.home-ask { margin-top: 12px; display: grid; gap: 8px; }
.home-ask .card { display: flex; justify-content: space-between; gap: 10px; align-items: center; cursor: pointer; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 8px; scrollbar-width: none; }
.tabs button { background: var(--panel); color: var(--muted); border: 1px solid var(--line); border-radius: 99px;
  padding: 7px 12px; font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--accent-ink); background: var(--accent); border-color: transparent; }
.tabs button b { margin-left: 4px; }
#funnel-bulk { margin-bottom: 10px; }
.lead { display: grid; gap: 6px; }
.lead-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.lead .score { background: var(--panel2); color: var(--accent); border-radius: 8px; padding: 2px 8px; font-weight: 700; }
.lead .meta { color: var(--muted); font-size: 13px; }
.lead a.meta { text-decoration: none; }
.lead .warn { color: var(--warn); }
.checks { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; }
.checks .yes { color: var(--accent); }
.checks .no { color: var(--warn); }
.lead .draft { background: var(--panel2); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; font-size: 14px; }
.lead .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.mobile-only { display: none; }
@media (max-width: 760px) {
  .side { display: none; }
  .mobile-only { display: flex; }
  main { padding: 14px 16px 92px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats .stat:nth-child(3):last-child { grid-column: span 2; }
  .bottom { position: fixed; bottom: 0; left: 0; right: 0; background: #0e1626; border-top: 1px solid var(--line);
    justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom a { flex-direction: column; gap: 2px; font-size: 12px; padding: 6px 4px; }
  .bottom a.active { color: var(--accent); }
  .chat-view { height: calc(100vh - 170px); }
  .msg { max-width: 88%; }
}
