/* GEO Командный центр — админка, дизайн-система «Завод 2.0» */
:root {
  --bg: #f1efea; --surface: #fff; --hover: #ece9e3;
  --text: #1a1a1a; --muted: #6b6a65; --dim: #9a9892; --border: #e0ddd6;
  --lime: #d6f24e; --danger: #c0392b; --success: #22c55e;
  --tone-blue: #bfd4e8; --tone-yellow: #f5d92a; --tone-sage: #c8e6b0;
  --tone-lavender: #d9c8ea; --tone-peach: #f0d4bd;
  --sidebar-w: 230px; --sidebar-w-collapsed: 60px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: 'Inter Tight', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
em.serif { font-family: 'Instrument Serif', serif; font-style: italic; font-weight: 400; }
a { color: inherit; }
svg { display: inline-block; vertical-align: middle; }

/* login */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 40px; width: 340px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.login-card .avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--lime); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; font-size: 26px; }
.login-card h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.login-card input { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 999px; font: inherit; margin: 16px 0 10px; text-align: center; }
.login-card button { width: 100%; padding: 11px; border: none; border-radius: 999px; background: #1a1a1a; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.login-card .err { color: var(--danger); font-size: 12px; min-height: 16px; margin-top: 8px; }

/* shell */
#app { display: none; min-height: 100vh; }
#app.on { display: grid; grid-template-columns: var(--sidebar-w) 1fr; transition: grid-template-columns .22s ease; }
#app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.sidebar {
  border-right: 1px solid var(--border); padding: 16px 12px;
  display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; padding: 0 6px; }
.wordmark { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
#app.collapsed .wordmark-txt { display: none; }
.collapse-btn { background: none; border: none; padding: 6px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.collapse-btn:hover { background: var(--hover); color: var(--text); }
.nav-group { margin: 12px 6px 4px; font-family: 'JetBrains Mono', monospace; font-size: 9px; text-transform: uppercase; color: var(--dim); letter-spacing: .08em; }
#app.collapsed .nav-group { visibility: hidden; height: 6px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  cursor: pointer; color: var(--text); text-decoration: none; font-weight: 500;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--lime); font-weight: 600; }
.nav-item svg { flex-shrink: 0; }
#app.collapsed .nav-label { display: none; }
#app.collapsed .nav-item { justify-content: center; padding: 8px 6px; }
.folder-toggle { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; cursor: pointer; user-select: none; font-weight: 600; }
.folder-toggle:hover { background: var(--hover); border-radius: 10px; }
.folder-body { padding-left: 12px; display: none; }
.folder-body.on { display: block; }

.main { padding: 26px 34px 100px; max-width: 1400px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.crumbs { color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.brains { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; }
.brains .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone-sage); }
h2.hero { font-size: 40px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; margin: 6px 0 26px; }

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 16px; }
.stat b { display: block; font-size: 30px; font-weight: 800; margin-top: 6px; }
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.proj { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; cursor: pointer; text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.proj:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.proj .preview { aspect-ratio: 16/10; background: linear-gradient(135deg, var(--tone-blue), var(--tone-lavender)); position: relative; display: flex; align-items: center; justify-content: center; color: rgba(0,0,0,.35); font-family: 'JetBrains Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.proj .preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.proj .status-badge { position: absolute; top: 10px; left: 10px; font-family: 'JetBrains Mono', monospace; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.9); }
.proj .body { padding: 14px 16px 16px; flex: 1; }
.proj h3 { margin: 4px 0; font-size: 17px; font-weight: 700; }
.proj .niche { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.proj-add { border: 2px dashed var(--border); border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--dim); min-height: 240px; cursor: pointer; font-family: 'JetBrains Mono', monospace; text-transform: uppercase; font-size: 11px; letter-spacing: .06em; }
.proj-add:hover { border-color: var(--lime); color: var(--text); }
.proj-add .big { font-size: 32px; margin-bottom: 4px; }

/* kanban */
.kb-actions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.pill-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 8px 18px; font: inherit; font-weight: 600; cursor: pointer; font-size: 13px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.pill-btn.primary { background: var(--lime); border-color: var(--lime); }
.pill-btn.danger { color: var(--danger); border-color: var(--danger); }
.pill-btn:disabled { opacity: .5; cursor: not-allowed; }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 12px; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.filter-label { font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; color: var(--dim); margin-right: 4px; }
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }
.col { background: rgba(255,255,255,.55); border: 1px solid var(--border); border-radius: 18px; padding: 10px; min-height: 300px; }
.col-head { display: flex; justify-content: space-between; padding: 4px 6px 10px; }
.col-head strong { font-family: 'JetBrains Mono', monospace; font-size: 11px; text-transform: uppercase; color: var(--text); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.04); position: relative; }
.card:hover { border-color: var(--dim); }
.card.dragging { opacity: .4; }
.card .title { font-weight: 600; font-size: 13px; line-height: 1.35; margin: 6px 0 6px; }
.badges { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.badge { font-family: 'JetBrains Mono', monospace; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; padding: 2px 6px; border-radius: 999px; background: var(--hover); color: var(--muted); border: 1px solid var(--border); }
.badge.id { background: #1a1a1a; color: #fff; cursor: pointer; border-color: #1a1a1a; }
.badge.id:hover { background: var(--lime); color: #1a1a1a; border-color: var(--lime); }
.badge.comments-count { background: var(--tone-yellow); color: #6b4c00; border-color: #f0c800; }
.col.drag-over { outline: 2px dashed var(--lime); }
.card .card-drag { position: absolute; top: 6px; right: 26px; cursor: grab; color: var(--dim); opacity: 0; transition: opacity .15s; padding: 2px; }
.card:hover .card-drag { opacity: 1; }
.card .del { position: absolute; top: 6px; right: 6px; border: none; background: none; color: var(--dim); cursor: pointer; font-size: 12px; padding: 4px; line-height: 1; }
.card .del:hover { color: var(--danger); }
.card.flash { outline: 3px solid var(--lime); }
.saving { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--muted); margin-left: 8px; }

/* list-card generic */
.list-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 6px 4px; }
.list-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); align-items: center; cursor: pointer; }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--hover); }
.list-row.active { background: var(--lime); }
.list-row strong { font-weight: 600; }
.list-row .meta { color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; }

/* md-editor */
.md-shell { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.md-editor { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px; min-height: 500px; display: flex; flex-direction: column; gap: 10px; }
.md-editor .path { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--muted); }
.md-editor textarea { flex: 1; min-height: 400px; border: 1px solid var(--border); border-radius: 12px; padding: 14px; font-family: 'JetBrains Mono', monospace; font-size: 12px; line-height: 1.55; resize: vertical; }
.md-editor .actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

/* project dashboard */
.pj-shell { display: grid; grid-template-columns: 260px 1fr 1fr; gap: 14px; align-items: start; }
.pj-info { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px; position: sticky; top: 20px; }
.pj-info h3 { margin: 8px 0; font-size: 18px; }
.pj-info dl { margin: 8px 0 0; font-size: 12px; }
.pj-info dt { font-family: 'JetBrains Mono', monospace; font-size: 9px; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.pj-info dd { margin: 2px 0; }
.pj-cat { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 12px; }
.pj-preview { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px; min-height: 400px; }
.pj-preview iframe { width: 100%; height: 500px; border: none; border-radius: 12px; }

/* Баги (Grandis-стиль карточек) */
.bugs-shell { display: flex; flex-direction: column; gap: 10px; }
.bug-card { display: flex; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; transition: opacity .3s; }
.bug-card.closed { opacity: .55; }
.bug-card.closed .bug-desc { text-decoration: line-through; color: var(--muted); }
.bug-body { flex: 1; min-width: 0; }
.bug-num { display: inline-block; font-size: 12px; font-weight: 700; color: var(--success); background: rgba(34,197,94,.12); border-radius: 6px; padding: 2px 8px; text-decoration: none; margin-right: 8px; }
.bug-card.closed .bug-num { color: #fff; background: #9ca3af; }
.bug-desc { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; margin: 8px 0; }
.bug-meta { font-size: 11px; color: var(--muted); }
.bug-meta a { color: var(--text); }
.bug-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.bug-btn { height: 28px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.bug-btn:hover { border-color: var(--text); color: var(--text); }
.bug-btn.fix { border-color: var(--success); color: var(--success); }
.bug-btn.fix:hover { background: var(--success); color: #fff; }
.bug-btn.reopen { border-color: #f59e0b; color: #f59e0b; }
.bug-empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 14px; }
.bug-section-head { font-family: 'JetBrains Mono', monospace; font-size: 11px; text-transform: uppercase; color: var(--dim); margin: 18px 0 10px; letter-spacing: .06em; }

/* chat dock */
.chat-dock { position: fixed; bottom: 0; left: var(--sidebar-w); right: 0; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 20px rgba(0,0,0,.05); transform: translateY(calc(100% - 40px)); transition: transform .25s, left .22s ease; z-index: 100; }
#app.collapsed ~ .chat-dock, body:has(#app.collapsed) .chat-dock { left: var(--sidebar-w-collapsed); }
.chat-dock.open { transform: translateY(0); }
.chat-dock .handle { padding: 8px 20px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.chat-dock .body { padding: 0 20px 16px; height: 280px; display: flex; flex-direction: column; }
.chat-dock .messages { flex: 1; overflow-y: auto; padding: 10px 0; font-size: 13px; line-height: 1.5; }
.chat-dock .input-row { display: flex; gap: 8px; }
.chat-dock input { flex: 1; border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font: inherit; }
@media (max-width: 900px) { .chat-dock { left: 0 !important; } }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; z-index: 200; }
.modal-bg.on { display: flex; }
.modal { background: var(--surface); border-radius: 20px; padding: 28px; max-width: 640px; width: 92%; max-height: 90vh; overflow-y: auto; position: relative; }
/* macOS traffic-light close button — маленький красный круг в правом верхнем углу */
.mac-close {
  position: absolute; top: 14px; right: 14px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #ff5f57; border: 0.5px solid rgba(0,0,0,.15);
  cursor: pointer; padding: 0;
  box-shadow: inset 0 0.5px 0 rgba(255,255,255,.35);
  transition: background .12s;
}
.mac-close:hover { background: #ff3b30; }
.mac-close:hover::after {
  content: '×';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: rgba(0,0,0,.55); font-size: 12px; font-weight: 700; line-height: 1;
}
.modal h3 { margin: 0 0 12px; }
.modal input, .modal select, .modal textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; margin: 6px 0 12px; }
.modal textarea { min-height: 80px; resize: vertical; }
.modal .row-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.modal .warn { background: color-mix(in srgb, var(--danger) 8%, transparent); border: 1px solid var(--danger); border-radius: 12px; padding: 12px 14px; color: var(--danger); font-size: 13px; margin: 8px 0; }
.modal label { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }

/* task modal (кликабельная карточка задачи с чатом-комментами) */
.task-modal .badges { margin-bottom: 12px; }
.task-modal .task-title-input { font-size: 18px; font-weight: 700; padding: 10px 14px; }
.task-chat { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 14px; }
.task-chat .comments { max-height: 260px; overflow-y: auto; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.task-comment { background: var(--hover); border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.45; }
.task-comment .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.task-comment .head strong { font-size: 12px; }
.task-comment .head .when { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--muted); text-transform: uppercase; }
.task-comment.own { background: color-mix(in srgb, var(--lime) 30%, var(--surface)); }
.task-comment.claude { background: color-mix(in srgb, var(--tone-lavender) 30%, var(--surface)); }
.task-chat-input { display: flex; gap: 8px; align-items: center; }
.task-chat-input input { flex: 1; padding: 9px 14px; border: 1px solid var(--border); border-radius: 999px; font: inherit; margin: 0; }

/* debug FAB (слева, полупрозрачный — как договорились) */
.debug-fab {
  position: fixed; left: calc(var(--sidebar-w) + 16px); bottom: 60px;
  z-index: 90; width: 44px; height: 44px; border-radius: 50%;
  background: var(--text); color: var(--lime); border: none; cursor: pointer;
  font-size: 20px; box-shadow: 0 4px 14px rgba(0,0,0,.2);
  opacity: .35; transition: opacity .2s, left .22s ease;
}
.debug-fab:hover { opacity: 1; background: var(--lime); color: var(--text); }
#app.collapsed ~ .debug-fab, body:has(#app.collapsed) .debug-fab { left: calc(var(--sidebar-w-collapsed) + 16px); }
@media (max-width: 900px) { .debug-fab { left: 16px !important; } }

@media (max-width: 900px) {
  #app.on { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .board { grid-template-columns: 1fr; }
  .md-shell, .pj-shell { grid-template-columns: 1fr; }
}
