:root {
  --bg: #f3f4f8;
  --panel: #ffffff;
  --side: #161b2e;
  --side-2: #20263d;
  --side-text: #c5cbe0;
  --text: #1c2233;
  --muted: #6b7489;
  --line: #e3e6ee;
  --accent: #4f7cff;
  --accent-2: #3d68e8;
  --danger: #e5484d;
  --ok: #22a55b;
  --warn: #f5a524;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .25);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff;
  padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; transition: .12s;
}
.btn:hover { border-color: #c9cfdc; background: #fafbfd; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 6px; color: var(--muted); line-height: 1; }
.icon-btn:hover { background: rgba(0,0,0,.06); color: var(--text); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 10px; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,124,255,.15); }
textarea.input { resize: vertical; min-height: 70px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.err { color: var(--danger); margin: 8px 0; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: #eef1f7; color: #4a5368; }
.pill.ok { background: #e3f6ec; color: #187a43; }
.pill.bad { background: #fdecec; color: #b3261e; }
.pill.blue { background: #e8eeff; color: #2f56c9; }
code.code { background: #eef1f7; padding: 2px 6px; border-radius: 6px; font-size: 13px; user-select: all; }

/* ---------- layout ---------- */
.layout { display: flex; height: 100vh; height: 100dvh; }
.sidebar {
  width: 250px; flex: none; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 14px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; font-weight: 700; font-size: 15px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; font-size: 15px; }
.brand small { display: block; font-weight: 400; color: #8a93b0; font-size: 11px; }
.nav-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6f7898; padding: 14px 10px 6px; display: flex; align-items: center; }
.nav-sec .icon-btn { color: #8a93b0; margin-left: auto; font-size: 16px; }
.nav-sec .icon-btn:hover { background: var(--side-2); color: #fff; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; color: var(--side-text); cursor: pointer; font-size: 14px;
}
.nav-item:hover { background: var(--side-2); color: #fff; }
.nav-item.active { background: #2b3352; color: #fff; }
.nav-item .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.nav-item .count { margin-left: auto; font-size: 12px; color: #7d86a5; }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-projects { overflow-y: auto; flex: 1; min-height: 60px; }
.side-foot { border-top: 1px solid #262d47; padding-top: 10px; margin-top: 8px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: none; }
.page { padding: 22px 26px; overflow: auto; flex: 1; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

/* ---------- avatars ---------- */
.ava {
  width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; flex: none;
  border: 2px solid #fff; text-transform: uppercase; letter-spacing: -.02em;
}
.ava.lg { width: 34px; height: 34px; font-size: 13px; }
.avas { display: inline-flex; }
.avas .ava + .ava { margin-left: -7px; }

/* ---------- board ---------- */
.board-head { padding: 14px 22px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.board-head h1 { display: flex; align-items: center; gap: 9px; }
.board-head .sq { width: 14px; height: 14px; border-radius: 4px; }
.board-tools { display: flex; gap: 8px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.board-tools .input { width: 200px; padding: 6px 10px; }
.board { flex: 1; overflow-x: auto; overflow-y: hidden; display: flex; gap: 14px; padding: 18px 22px; align-items: flex-start; }
.column {
  width: 290px; flex: none; background: #e9ebf2; border-radius: 12px; display: flex; flex-direction: column; max-height: 100%;
}
.col-head { padding: 10px 10px 8px 12px; display: flex; align-items: center; gap: 8px; cursor: grab; }
.col-head .bar { width: 4px; height: 16px; border-radius: 3px; }
.col-head .title { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-head .n { color: var(--muted); font-size: 12px; background: rgba(255,255,255,.7); border-radius: 99px; padding: 0 7px; }
.cards { padding: 2px 8px 4px; overflow-y: auto; min-height: 40px; flex: 1; }
.card {
  background: #fff; border-radius: 9px; padding: 9px 11px 8px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer;
  border-left: 3px solid transparent; transition: box-shadow .12s;
}
.card:hover { box-shadow: 0 3px 10px rgba(16,24,40,.12); }
.card.p1 { border-left-color: #22c55e; }
.card.p2 { border-left-color: #f5a524; }
.card.p3 { border-left-color: #e5484d; }
.card.done .card-title { color: var(--muted); text-decoration: line-through; }
.card-title { word-break: break-word; }
.card-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
.lbl { font-size: 11px; padding: 1px 7px; border-radius: 5px; background: #eef1f7; color: #4a5368; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.card-meta .avas { margin-left: auto; }
.dl { padding: 1px 6px; border-radius: 5px; background: #eef1f7; }
.dl.soon { background: #fff3dc; color: #a56500; }
.dl.over { background: #fdecec; color: #b3261e; }
.dl.ok { background: #e3f6ec; color: #187a43; }
.add-card { padding: 4px 8px 10px; }
.add-card .btn { width: 100%; justify-content: flex-start; background: transparent; border-color: transparent; color: var(--muted); }
.add-card .btn:hover { background: rgba(255,255,255,.6); color: var(--text); }
.add-col { width: 270px; flex: none; }
.sortable-ghost { opacity: .35; }
.sortable-drag { transform: rotate(2deg); }
.board-empty { margin: auto; text-align: center; color: var(--muted); }

/* ---------- menus / dropdowns ---------- */
.dd { position: relative; }
.menu {
  position: absolute; z-index: 50; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 6px; min-width: 200px; right: 0; top: calc(100% + 4px); max-height: 320px; overflow: auto;
}
.menu.left { left: 0; right: auto; }
.menu-item { padding: 7px 10px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.menu-item:hover { background: #f1f3f8; }
.menu-item.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 10px; }
.swatch { width: 20px; height: 20px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.swatch.on { border-color: var(--text); }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 20, 35, .45); z-index: 100; display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow: auto;
}
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; position: relative; }
.modal.wide { max-width: 1080px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- task modal ---------- */
.task { display: grid; grid-template-columns: minmax(0, 1fr) 380px; min-height: 70vh; }
.task-main { padding: 18px 22px; border-right: 1px solid var(--line); }
.task-title { width: 100%; font-size: 20px; font-weight: 650; border: 1px solid transparent; border-radius: 8px; padding: 4px 6px; margin: 0 -6px 8px; resize: none; outline: none; }
.task-title:hover { border-color: var(--line); }
.task-title:focus { border-color: var(--accent); }
.props { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px 12px; align-items: center; margin: 10px 0 18px; }
.props > .k { color: var(--muted); font-size: 13px; }
.props .input { padding: 5px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: #eef1f7; padding: 2px 4px 2px 2px; border-radius: 99px; font-size: 13px; }
.chip .ava { width: 20px; height: 20px; font-size: 9px; border: 0; }
.chip .x { cursor: pointer; color: var(--muted); padding: 0 4px; }
.chip.lbl-chip { padding: 2px 4px 2px 9px; }
.sec { margin-top: 20px; }
.sec h3 { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.desc-view { white-space: pre-wrap; word-break: break-word; padding: 8px 10px; border-radius: 8px; border: 1px dashed transparent; cursor: text; min-height: 40px; }
.desc-view:hover { border-color: var(--line); background: #fafbfd; }
.desc-view.empty { color: var(--muted); }
.check-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.check-item input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.check-item .t { flex: 1; }
.check-item.done .t { text-decoration: line-through; color: var(--muted); }
.check-item .icon-btn { opacity: 0; }
.check-item:hover .icon-btn { opacity: 1; }
.progress { height: 5px; background: #eef1f7; border-radius: 9px; overflow: hidden; flex: 1; max-width: 160px; }
.progress > div { height: 100%; background: var(--ok); }
.file { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; }
.file:hover { background: #f6f7fb; }
.file img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.file .ic { width: 40px; height: 40px; border-radius: 6px; background: #eef1f7; display: grid; place-items: center; font-size: 18px; }
.activity { font-size: 12px; color: var(--muted); }
.activity div { padding: 3px 0; }
.task-chat { display: flex; flex-direction: column; background: #f8f9fc; border-radius: 0 14px 14px 0; min-height: 0; max-height: calc(100vh - 80px); }
.chat-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.chat-list { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; min-height: 200px; }
.msg { display: flex; gap: 8px; }
.msg .bubble { background: #fff; border-radius: 4px 12px 12px 12px; padding: 7px 10px; box-shadow: var(--shadow); max-width: 100%; min-width: 0; }
.msg.mine { flex-direction: row-reverse; }
.msg.mine .bubble { background: #e6edff; border-radius: 12px 4px 12px 12px; }
.msg .who { font-size: 12px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.msg .who .t { font-weight: 400; color: var(--muted); }
.msg .text { white-space: pre-wrap; word-break: break-word; }
.msg .bubble img { max-width: 220px; max-height: 220px; border-radius: 8px; display: block; margin-top: 4px; }
.src { font-size: 10px; padding: 0 5px; border-radius: 4px; color: #fff; font-weight: 600; }
.src.telegram { background: #2aabee; }
.src.max { background: #7b5cff; }
.chat-input { border-top: 1px solid var(--line); padding: 10px; display: flex; gap: 6px; align-items: flex-end; background: #fff; border-radius: 0 0 14px 0; }
.chat-input textarea { min-height: 40px; max-height: 160px; resize: none; }
.chat-empty { color: var(--muted); text-align: center; margin: auto; font-size: 13px; padding: 20px; }

/* ---------- tables / lists ---------- */
.card-box { background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfd; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #fafbfd; }
.table tr.off td { opacity: .5; }
.tasklist .item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 8px; cursor: pointer; }
.tasklist .item:hover { box-shadow: 0 3px 10px rgba(16,24,40,.12); }
.tasklist h3 { margin: 18px 0 8px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.member-row:last-child { border-bottom: 0; }
.member-row select { width: 170px; }
.steps { margin: 6px 0 0; padding-left: 20px; }
.steps li { margin-bottom: 6px; }
.status-line { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 20%, #263056, #12162a 70%); padding: 20px; }
.login { background: #fff; border-radius: 16px; padding: 30px 28px; width: 100%; max-width: 370px; box-shadow: var(--shadow-lg); }
.login .brand { color: var(--text); padding: 0 0 20px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1c2233; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 200; box-shadow: var(--shadow-lg); max-width: 90vw; }
.toast.bad { background: #b3261e; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .task { grid-template-columns: 1fr; }
  .task-main { border-right: 0; border-bottom: 1px solid var(--line); }
  .task-chat { border-radius: 0 0 14px 14px; max-height: none; }
  .chat-list { max-height: 50vh; }
  .chat-input { border-radius: 0 0 14px 14px; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 90; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--side); color: #fff; }
  .topbar .icon-btn { color: #fff; font-size: 20px; }
  .page { padding: 16px; }
  .overlay { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
  .props { grid-template-columns: 100px minmax(0, 1fr); }
  .board { padding: 12px; }
  .column { width: 82vw; }
  .board-tools .input { width: 140px; }
  .table th:nth-child(n+4), .table td:nth-child(n+4) { display: none; }
}

/* ---------- client chats ---------- */
.chats { display: flex; height: 100%; min-height: 0; flex: 1; }
.chats-list { width: 340px; flex: none; border-right: 1px solid var(--line); background: #fff; overflow-y: auto; }
.chats-search { padding: 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.conv-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #f0f2f6; cursor: pointer; align-items: flex-start; }
.conv-item:hover { background: #f8f9fc; }
.conv-item.active { background: #eef3ff; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; line-height: 18px; font-weight: 600; }
.chat-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #f8f9fc; }
.chat-pane .chat-list { max-height: none; }
.chat-pane .chat-input { border-radius: 0; }
.chat-pane.chat-empty { align-items: center; justify-content: center; }
.icon-btn.back { display: none; font-size: 18px; }
.bot-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 760px) {
  .chats-list { width: 100%; }
  .chats-list.hide { display: none; }
  .chat-pane.chat-empty { display: none; }
  .icon-btn.back { display: inline-block; }
}
