:root {
  --border: #e2dfd8;
  --bg: #f7f6f3;
  --panel-bg: #ffffff;
  --surface-2: #f0eee9;
  --text: #1c1b1a;
  --muted: #6f6b65;
  --accent: #c65d34;
  --accent-ink: #a6502b;
  --accent-soft: #f3e0d4;
  --accent-faint: #c9a227;
  --tier2-soft: #dce3ea;
  --tier2-ink: #46556b;
  --danger: #b91c1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#brand { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
#brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }

.search-box { position: relative; width: 320px; }

#search-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--panel-bg);
  color: var(--text);
}

#suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 20;
}

.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
}

.suggestion:hover, .suggestion.active { background: var(--accent-soft); }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #b9b2a6;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.avatar.big { width: 64px; height: 64px; font-size: 20px; }
.avatar.selected { background: var(--accent-soft); color: var(--accent-ink); border: 2px solid var(--accent); }

.suggestion-info { line-height: 1.3; }
.suggestion-name { font-weight: 600; font-size: 14px; }
.suggestion-meta { font-size: 12px; color: var(--muted); }

#breadcrumbs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13px;
  align-items: center;
}

#breadcrumbs .crumb {
  cursor: pointer;
  color: var(--accent-ink);
}

#breadcrumbs .crumb:hover { text-decoration: underline; }

#breadcrumbs .sep { color: var(--muted); }

main {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr 320px;
  grid-template-rows: minmax(0, 1fr); /* без этого ряд растягивается под контент (таблицу коллег) и граф уезжает за экран */
  min-height: 0;
}

#filters, #panel {
  background: var(--panel-bg);
  overflow-y: auto;
  padding: 14px;
  min-height: 0;
}

#filters { border-right: 1px solid var(--border); }
#panel { border-left: 1px solid var(--border); }

#filters h2, #panel h2 { font-size: 14px; margin: 0 0 10px; }
.filter-group { margin-bottom: 18px; }
.filter-group h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.filter-group label { display: block; font-size: 13px; margin-bottom: 4px; cursor: pointer; }
.filter-group input[type="number"], .filter-group select { width: 100%; padding: 4px; border: 1px solid var(--border); border-radius: 4px; background: var(--panel-bg); color: var(--text); }
.filter-group input[type="checkbox"], .filter-group input[type="range"] { accent-color: var(--accent); }
.filter-group .hint { font-size: 11px; color: var(--muted); margin: 4px 0 0; }
.tier-label { font-size: 11px; color: var(--muted); margin: 8px 0 2px; }

#reset-filters {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

#graph-container { position: relative; min-width: 0; }
#graph { width: 100%; height: 100%; }

#graph-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--muted);
  background: rgba(247, 246, 243, 0.85);
  text-align: center;
  padding: 20px;
}

#graph-state.error { color: var(--danger); }

/* [hidden] (атрибут) проигрывает по специфичности правилу #graph-state{display:flex}
   выше — без этого переопределения полупрозрачная подложка оверлея никогда не
   скрывается и "забеливает" весь граф поверх (это и выглядело как "блюр" на фото). */
#graph-state[hidden] { display: none; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border); }
th { cursor: pointer; color: var(--muted); font-weight: 600; user-select: none; }
th:hover { color: var(--text); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
.pair-btn { font-size: 11px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--panel-bg); color: var(--text); cursor: pointer; }
.pair-btn:hover { background: var(--accent-soft); }

#pair-back {
  font-size: 12px;
  border: none;
  background: none;
  color: var(--accent-ink);
  cursor: pointer;
  padding: 0 0 14px;
  display: block;
}

/* Отчёт пары: карточный вид вместо таблицы */
#pair-people { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.pair-link-icon { font-size: 15px; color: var(--muted); flex-shrink: 0; }
.pair-person-info { line-height: 1.3; min-width: 0; }
.pair-person-name { font-weight: 700; font-size: 14px; }
.pair-person-role { font-size: 12px; color: var(--muted); }

#pair-stats { display: flex; gap: 10px; margin-bottom: 14px; }
.stat-card { flex: 1; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat-value { font-size: 18px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--muted); }

.panel-divider { height: 1px; background: var(--border); margin-bottom: 14px; }
.panel-section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}

.pair-project-row { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.pair-project-row:last-child { border-bottom: none; }
.pair-project-year { width: 38px; flex-shrink: 0; font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 1px; }
.pair-project-main { flex: 1; min-width: 0; }
.pair-project-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.pair-project-roles { display: flex; gap: 6px; flex-wrap: wrap; }
.role-pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.role-pill-a { background: var(--accent-soft); color: var(--accent-ink); }
.role-pill-b { background: var(--tier2-soft); color: var(--tier2-ink); }

#footer-stats {
  flex-shrink: 0;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
}

/* Мобильные фильтры (FAB + выезжающая панель) и панель (bottom sheet) —
   скрыты на десктопе, задействуются только в мобильной медиа-запросе ниже. */
#filters-fab { display: none; }
#filters-backdrop { display: none; }
#panel-handle { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --border: #333a46;
    --bg: #15181f;
    --panel-bg: #1b1f27;
    --surface-2: #232834;
    --text: #e6e8ec;
    --muted: #9099a8;
    --accent: #e0935f;
    --accent-ink: #f0ad7d;
    --accent-soft: #3a2b22;
    --accent-faint: #d9b24c;
    --tier2-soft: #263142;
    --tier2-ink: #9db4d6;
    --danger: #f87171;
  }
  tbody tr:hover { background: var(--surface-2); }
  .suggestion:hover, .suggestion.active { background: var(--surface-2); }
  .pair-btn { background: var(--panel-bg); color: var(--text); }
  #graph-state { background: rgba(21, 24, 31, 0.85); }
}

/* --- Мобильная адаптация (см. docs/UI-NOTES.md, запись 2026-11-14) ---------------
   Боковая сетка 220px/1fr/320px не влезает на экранах уже около 540–900px:
   фильтры становятся выезжающей панелью за FAB-кнопкой, правая панель —
   bottom sheet поверх графа вместо третьей колонки. */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }

  #brand-name { display: none; } /* логотип-иконка остаётся, слово уступает место поиску */
  .search-box { width: auto; flex: 1; }
  #breadcrumbs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }

  #filters-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: 16px;
    bottom: 76px; /* выше свёрнутой панели */
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--text);
    border: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    z-index: 60;
    cursor: pointer;
  }
  .fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #filters-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 55;
  }
  #filters-backdrop[hidden] { display: none; }

  #filters {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    max-width: 85vw;
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 56;
  }
  #filters.open { transform: translateX(0); }

  #panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    max-height: 70vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(0);
    transition: transform 0.2s ease;
    z-index: 50;
    padding-top: 6px;
  }
  #panel.collapsed { transform: translateY(calc(100% - 56px)); }

  #panel-handle {
    display: flex;
    justify-content: center;
    width: 100%;
    border: none;
    background: none;
    padding: 6px 0 10px;
    cursor: pointer;
  }
  .handle-bar { width: 36px; height: 4px; border-radius: 2px; background: var(--border); }
}
