:root {
  --bg: #07090d;
  --sidebar: #0c0f15;
  --panel: #11151d;
  --panel-2: #151b25;
  --panel-3: #1a2130;
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.14);
  --text: #f4f7fb;
  --muted: #97a3b6;
  --blue: #68a9ff;
  --green: #72df8d;
  --yellow: #f4c15d;
  --red: #ff6b7d;
  --purple: #aa7cff;
  --gray: #7d8696;
  --shadow: 0 24px 60px rgba(0,0,0,0.35);
  --radius: 22px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(104,169,255,0.08), transparent 25%),
    radial-gradient(circle at top right, rgba(170,124,255,0.08), transparent 20%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}
.app {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  background: rgba(10,12,18,0.95);
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  box-shadow: var(--shadow);
}
.brand h1 { margin: 0; font-size: 17px; letter-spacing: -0.02em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.nav-section { margin-bottom: 22px; }
.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 10px;
  padding: 0 10px;
}
.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  background: transparent;
  color: #dce5f5;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 11px 12px;
  margin-bottom: 4px;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.nav-link:hover, .nav-link.active { background: var(--panel-2); border-color: var(--line); }
.nav-meta { color: var(--muted); font-size: 12px; }
.sidebar-card {
  margin-top: 20px;
  padding: 14px;
  background: linear-gradient(180deg, var(--panel), rgba(17,21,29,0.65));
  border: 1px solid var(--line);
  border-radius: 18px;
}
.sidebar-card h3 { margin: 0 0 6px; font-size: 14px; }
.sidebar-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.main { padding: 22px; overflow: auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-title { margin: 0; font-size: 30px; letter-spacing: -0.04em; }
.page-subtitle { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 760px; }
.status-row { display: flex; gap: 10px; flex-wrap: wrap; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 12px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.dot.active { background: var(--green); }
.dot.pending { background: var(--yellow); }
.dot.error { background: var(--red); }
.dot.idle { background: var(--gray); }
.screen { display: none; }
.screen.active { display: block; }
#screen-chat.active {
  display: flex;
  flex-direction: column;
  height: clamp(420px, calc(100vh - 260px), 680px);
  min-height: 420px;
}
.split { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 16px; }
.panel {
  background: linear-gradient(180deg, rgba(21,27,37,0.95), rgba(16,20,28,0.98)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.panel-head { padding: 18px 20px 0; }
.panel-head h3 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.panel-head p { margin: 7px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 16px 0; }
.metric {
  background: linear-gradient(180deg, var(--panel), rgba(17,21,29,0.78)); border: 1px solid var(--line); border-radius: 18px; padding: 16px;
}
.metric-label { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.metric-value { font-size: 30px; font-weight: 700; letter-spacing: -0.05em; }
.metric-sub { margin-top: 6px; color: #d6deef; font-size: 13px; line-height: 1.45; }
.list { padding: 10px 0 14px; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; border-top: 1px solid var(--line); padding: 14px 20px;
}
.row:first-child { border-top: 0; }
.row-title { font-weight: 600; }
.row-sub { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.badge {
  border: 1px solid var(--line-strong); color: var(--muted); border-radius: 999px; padding: 5px 8px; font-size: 12px; white-space: nowrap;
}
.board, .content-board {
  display: grid; gap: 14px; overflow-x: auto; padding-bottom: 6px;
}
.board { grid-template-columns: repeat(4, minmax(240px, 1fr)); }
.content-board { grid-template-columns: repeat(7, minmax(230px, 1fr)); }
.column {
  min-width: 240px; background: linear-gradient(180deg, rgba(17,21,29,0.98), rgba(16,20,28,0.95)); border: 1px solid var(--line); border-radius: 18px; padding: 14px;
}
.column h4 { margin: 0 0 12px; font-size: 14px; letter-spacing: -0.01em; }
.card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 10px; cursor: grab;
}
.card:last-child { margin-bottom: 0; }
.card.dragging { opacity: 0.45; }
.column.drag-over { outline: 1px dashed var(--blue); outline-offset: 4px; }
.card-title { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.meta-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  font-size: 11px; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 7px;
}
.card-text { color: #dbe3f4; font-size: 13px; line-height: 1.45; }
.expand { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.tool {
  padding: 8px 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 12px;
}
.editor-grid { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 16px; margin-top: 16px; }
.editor-panel { padding: 18px; }
.field, .textarea, .select {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--text); padding: 10px 12px; font: inherit; margin-top: 8px;
}
.textarea { min-height: 120px; resize: vertical; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.button {
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: linear-gradient(135deg, var(--blue), #4f7cff); color: white; font: inherit; cursor: pointer;
}
.button.secondary { background: var(--panel-3); color: var(--text); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; padding: 18px; }
.day { min-height: 130px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,0.02); padding: 12px; }
.day h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.event { border-radius: 12px; padding: 8px; margin-bottom: 8px; font-size: 12px; line-height: 1.4; color: white; }
.event.blue { background: rgba(104,169,255,0.24); border: 1px solid rgba(104,169,255,0.45); }
.event.green { background: rgba(114,223,141,0.22); border: 1px solid rgba(114,223,141,0.4); }
.event.purple { background: rgba(170,124,255,0.22); border: 1px solid rgba(170,124,255,0.42); }
.event.gray { background: rgba(125,134,150,0.2); border: 1px solid rgba(125,134,150,0.38); }
.search-bar {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--text); padding: 12px 14px; font: inherit; margin: 16px 0;
}
.memory-grid, .crm-grid, .team-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.memory-card, .crm-card, .team-card {
  background: linear-gradient(180deg, var(--panel), rgba(17,21,29,0.84)); border: 1px solid var(--line); border-radius: 18px; padding: 16px;
}
.memory-card h4, .crm-card h4, .team-card h4 { margin: 0 0 8px; font-size: 16px; }
.memory-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.memory-preview {
  color: #dbe3f4;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.memory-path {
  color: var(--muted);
  font-size: 11px;
  word-break: break-all;
}
.memory-empty {
  grid-column: 1 / -1;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255,255,255,0.02);
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.org-root { display: flex; justify-content: center; margin: 16px 0 20px; }
.root-card {
  width: 320px; background: linear-gradient(135deg, rgba(104,169,255,0.14), rgba(170,124,255,0.12)); border: 1px solid var(--line-strong); border-radius: 20px; padding: 18px; text-align: center;
}
.avatar { width: 54px; height: 54px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--purple)); margin: 0 auto 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chat-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  height: 100%;
  min-height: 0;
}
.chat-sidebar {
  background: linear-gradient(180deg, var(--panel), rgba(17,21,29,0.84));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  overflow: auto;
  min-height: 0;
}
.chat-thread-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.chat-thread {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,0.02);
  cursor: pointer;
}
.chat-thread.active {
  border-color: rgba(104,169,255,0.35);
  background: rgba(104,169,255,0.08);
}
.chat-main {
  background: linear-gradient(180deg, var(--panel), rgba(17,21,29,0.84));
  border: 1px solid var(--line);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.chat-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(10,12,18,0.92);
}
.chat-messages {
  flex: 1;
  min-height: 0;
  padding: 16px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}
.chat-bubble {
  max-width: 72%;
  padding: 10px 13px;
  border-radius: 18px;
  border: 1px solid var(--line);
  line-height: 1.45;
  font-size: 14px;
}
.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(104,169,255,0.92), rgba(79,124,255,0.92));
  border-color: rgba(104,169,255,0.35);
  color: white;
  border-bottom-right-radius: 8px;
}
.chat-bubble.agent {
  align-self: flex-start;
  background: rgba(255,255,255,0.045);
  border-bottom-left-radius: 8px;
}
.chat-meta {
  margin-top: 5px;
  color: rgba(255,255,255,0.62);
  font-size: 11px;
}
.chat-composer {
  position: sticky;
  bottom: 0;
  border-top: 1px solid var(--line);
  padding: 12px 16px 14px;
  background: rgba(10,12,18,0.96);
  backdrop-filter: blur(10px);
}
.chat-input {
  width: 100%;
  min-height: 54px;
  max-height: 140px;
  resize: vertical;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  font: inherit;
  padding: 14px 15px;
}
.chat-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}
.quick-prompts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.quick-prompt {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3,5,10,0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(760px, 100%);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 20px; }
.modal-body { padding: 18px 20px 22px; }
.modal-close {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.detail-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.detail-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.detail-value { font-size: 14px; line-height: 1.5; color: #dde6f5; }
@media (max-width: 1200px) {
  .metric-grid, .memory-grid, .crm-grid, .team-grid, .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .editor-grid, .chat-layout { grid-template-columns: 1fr; }
  #screen-chat.active { height: clamp(400px, calc(100vh - 220px), 620px); min-height: 400px; }
}
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .metric-grid, .memory-grid, .crm-grid, .team-grid, .settings-grid { grid-template-columns: 1fr; }
  .calendar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  #screen-chat.active { height: clamp(360px, calc(100vh - 180px), 560px); min-height: 360px; }
}
