:root {
  --bg: #0e1020;
  --panel: #161a2e;
  --panel-2: #1e2440;
  --line: #2a3252;
  --text: #e8ebf5;
  --muted: #8b93ad;
  --accent: #5b8cff;
  --green: #34c759;
  --amber: #ffb020;
  --red: #ff5a5f;
  --violet: #b06bff;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  /* фиолетовое свечение вокруг приложения, как в референсе */
  background: radial-gradient(1200px 700px at 50% -10%, #3a2d7a 0%, #15132e 45%, #0a0a14 100%);
  padding: 10px;
}

/* Рамка-окно со свечением */
.layout {
  display: flex;
  height: calc(100vh - 20px);
  background: var(--bg);
  border: 1.5px solid #5b6cff;
  border-radius: 16px;
  box-shadow: 0 0 50px rgba(91, 108, 255, 0.45), inset 0 0 0 1px rgba(255,255,255,0.02);
  overflow: hidden;
}

.muted { color: var(--muted); font-size: 13px; }

/* Кнопки */
.btn { border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-green { background: var(--green); border-color: var(--green); color: #042; font-weight: 600; }
.btn-amber { background: var(--amber); border-color: var(--amber); color: #421; font-weight: 600; }
.icon-btn { background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1; padding: 6px 10px; }
.icon-btn:hover { border-color: var(--accent); }
.hidden { display: none !important; }

/* ── Боковое меню ── */
.sidebar { width: 240px; min-width: 240px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding: 0 6px; }
.brand .logo { font-size: 24px; }
.brand .title { font-weight: 700; font-size: 15px; }
.brand .subtitle { font-size: 12px; color: var(--muted); }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted);
  padding: 0 8px; margin-bottom: 8px; }
.project-nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; flex: 1; }
.nav-item { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; color: var(--text); cursor: pointer; font-size: 13px;
  text-decoration: none; border: 1px solid transparent; }
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: var(--panel-2); border-color: var(--accent); }
.nav-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cnt { font-size: 11px; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 1px 7px; }
.ren { background: none; border: none; cursor: pointer; font-size: 12px; opacity: 0.45; padding: 0 2px; }
.nav-item:hover .ren { opacity: 0.9; }
.ren:hover { opacity: 1; }
.sidebar-bottom { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.layout.collapsed .sidebar { display: none; }

/* ── Основная колонка ── */
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.board-title { font-weight: 700; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-box { color: var(--text); font-size: 13px; opacity: 0.9; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--green); } .dot.bad { background: var(--red); }

.content { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.content-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 22px 6px; }
.page-title { margin: 0; font-size: 20px; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.mode-switch { display: flex; align-items: center; gap: 8px; }
.mode-btn { border: 1px solid var(--line); background: transparent; color: var(--muted);
  padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.mode-btn.active { background: var(--amber); border-color: var(--amber); color: #311; font-weight: 700; }

/* ── Канбан ── */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr);
  gap: 14px; padding: 14px 22px 20px; overflow-x: auto; align-items: start;
  flex: none; height: 58vh; min-height: 360px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; max-height: 100%; }
.col-head { padding: 12px 14px; font-size: 12px; display: flex; justify-content: space-between;
  align-items: center; border-bottom: 1px solid var(--line); }
.col-name { display: flex; align-items: center; gap: 8px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.4px; }
.col-count { color: var(--muted); }
.col-accent { width: 22px; height: 3px; border-radius: 3px; display: inline-block; }
.col-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 80px; }
.col-body.drag-over { background: rgba(91,140,255,0.10); outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: 10px; }
.drop-hint { border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 12px;
  text-align: center; padding: 16px 8px; }

.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font-size: 13px; }
.card[draggable=true] { cursor: grab; }
.card.dragging { opacity: 0.5; }
.card .agent { display: inline-block; font-size: 11px; color: var(--accent); font-weight: 700;
  background: rgba(91,140,255,0.12); padding: 2px 7px; border-radius: 6px; }
.card .kind { display: inline-block; font-size: 11px; color: var(--amber); font-weight: 700;
  background: rgba(255,176,32,0.14); padding: 2px 7px; border-radius: 6px; margin-left: 4px; }
.card .proj { color: var(--muted); font-size: 11px; margin-top: 6px; }
.card .type { margin: 7px 0 3px; font-weight: 600; line-height: 1.3; }
.card .date { color: var(--muted); font-size: 12px; }
.card .note { color: var(--muted); font-size: 12px; margin-top: 7px; font-style: italic; }
.card .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ── Список ── */
.list-view { flex: 1; overflow: auto; padding: 8px 22px 20px; }
.task-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.task-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); }
.task-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.task-table tr:hover td { background: var(--panel); }
.chip { border: 1px solid; border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── Модалка ── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex;
  align-items: center; justify-content: center; z-index: 10; }
.modal.hidden { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: 400px; }
.modal-card h3 { margin: 0 0 14px; }
.modal-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.modal-card input, .modal-card select { width: 100%; margin-top: 5px; padding: 9px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ── Вход ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: 360px; text-align: center; }
.login-card .logo { font-size: 32px; }
.login-card h2 { margin: 10px 0 6px; font-size: 18px; }
.login-card label { display: block; text-align: left; font-size: 12px; color: var(--muted); margin: 14px 0 0; }
.login-card input { width: 100%; margin-top: 5px; padding: 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 14px; }
.login-err { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ── Люди ── */
.people-wrap { max-width: 760px; margin: 24px auto; padding: 0 18px; display: flex; flex-direction: column; gap: 18px; }
.people-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.people-card h3 { margin: 0 0 8px; }
.people-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: end; margin-top: 12px; }
.people-form label { font-size: 12px; color: var(--muted); display: block; }
.people-form input, .people-form select { width: 100%; margin-top: 5px; padding: 9px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 14px; }
.invite-box { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--panel-2);
  border: 1px solid var(--line); font-size: 13px; line-height: 1.5; }
.invite-box code { word-break: break-all; }
.person { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.person-actions { display: flex; gap: 8px; align-items: center; }
.role-sel { padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 13px; }

/* Описание проекта */
.project-info { display: flex; align-items: flex-start; gap: 12px; padding: 12px 22px;
  border-bottom: 1px solid var(--line); background: var(--panel); }
.proj-icon { font-size: 22px; line-height: 1; padding-top: 2px; }
.proj-text { flex: 1; min-width: 0; }
.proj-name { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.proj-desc { color: var(--muted); font-size: 13px; white-space: pre-wrap; line-height: 1.45; }
.modal-card textarea { width: 100%; margin-top: 5px; padding: 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 13px;
  font-family: inherit; resize: vertical; min-height: 90px; }

/* Правая панель проекта */
.right-panel { width: 320px; min-width: 320px; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden; }
.rp-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex;
  justify-content: space-between; align-items: center; gap: 8px; }
.rp-title { font-weight: 700; font-size: 14px; }
.rp-body { padding: 14px 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.rp-section { margin-bottom: 18px; }
.rp-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 8px; }
.rp-desc { white-space: pre-wrap; color: var(--text); font-size: 13px; line-height: 1.5; }
.flow-step { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.flow-step-text { font-size: 12.5px; line-height: 1.45; }
.flow-link { display: inline-block; margin-top: 6px; color: var(--accent); text-decoration: none; font-size: 12px; }
.flow-link:hover { text-decoration: underline; }
.flow-arrow { text-align: center; color: var(--muted); font-size: 14px; margin: 4px 0; }
.flow-empty { color: var(--muted); font-size: 12px; padding: 8px 0; }

/* Блок-схема под доской */
.project-flow { padding: 18px 22px 28px; border-top: 1px solid var(--line); background: var(--bg); }
.pf-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); margin-bottom: 14px; }
.pf-row { display: flex; flex-wrap: wrap; align-items: stretch; gap: 4px; }
.pf-step { background: var(--panel-2); border: 1.5px solid var(--accent); border-radius: 12px;
  padding: 12px 14px; min-width: 190px; max-width: 240px; display: flex; flex-direction: column;
  gap: 8px; box-shadow: 0 0 16px rgba(91,140,255,0.15); }
.pf-text { font-size: 13px; line-height: 1.45; flex: 1; }
.pf-link { color: var(--accent); text-decoration: none; font-size: 12px; font-weight: 600; }
.pf-link:hover { text-decoration: underline; }
.pf-arrow { display: flex; align-items: center; color: var(--accent); font-size: 22px; font-weight: 700; padding: 0 4px; }

/* Детальная карточка задачи */
.task-detail { width: 620px; max-width: 92vw; max-height: 88vh; overflow-y: auto; }
.td-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.td-meta { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; flex-wrap: wrap; }
.td-section { margin-top: 16px; }
.td-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 8px; }
.td-note { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.td-agent-box { background: var(--panel-2); border: 1px dashed var(--accent); border-radius: 10px;
  padding: 14px 16px; font-size: 13px; line-height: 1.55; color: var(--text); }
.td-agent-box b { color: var(--amber); }
.td-timeline { display: flex; flex-direction: column; gap: 6px; }
.td-tl-item { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; line-height: 1.4; }
.td-tl-time { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.td-tl-by { color: var(--accent); font-weight: 600; }
.task-detail .card { cursor: default; }
.card { cursor: pointer; }

/* Каталог отчётов проекта */
.rp-reports-cat { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--amber); margin: 14px 0 6px; }
.rp-reports-cat:first-child { margin-top: 4px; }
.report-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; margin-bottom: 6px; font-size: 12.5px; line-height: 1.4; }
.report-name { font-weight: 700; margin-bottom: 3px; }
.report-meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.report-desc { color: var(--text); opacity: 0.8; margin-top: 4px; font-size: 12px; }
.report-actions { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.report-actions .btn { font-size: 11.5px; padding: 4px 8px; }
.report-actions a { font-size: 11.5px; }
