/* ============================================================
   Dev Tester — Industrial Tech themes (light + dark)
   Палитра/типографика по DESIGN.md (Hanken Grotesk + JetBrains Mono)
   ============================================================ */

* { box-sizing: border-box; }

:root {
  /* ── Light theme (default) ── */
  --bg:                  #f7f9fc;
  --bg-grid:             #d8dadd;
  --surface:             #ffffff;
  --surface-alt:         #eceef1;
  --surface-high:        #e0e3e6;
  --text:                #191c1e;
  --text-muted:          #434656;
  --text-faint:          #737688;
  --border:              #c3c5d9;
  --border-strong:       #737688;

  --primary:             #003ec7;
  --primary-hover:       #0030a0;
  --primary-soft:        #dfe3ff;
  --secondary:           #fe6b00;          /* safety orange */
  --secondary-soft:      #ffdbcc;
  --tertiary:            #3f4f65;
  --success:             #1a7f37;
  --warn:                #fe6b00;
  --danger:              #ba1a1a;
  --danger-soft:         #ffdad6;

  /* Цвет текста поверх цветных плашек (primary/danger/success/priority).
     В light theme плашки тёмные/насыщенные — нужен белый. В dark — наоборот. */
  --on-tint:             #ffffff;
  /* Алиас для старых правил, использовавших var(--accent) — это primary. */
  --accent:              #003ec7;

  --col-backlog:         #737688;
  --col-progress:        #003ec7;
  --col-review:          #5a3acf;
  --col-testing:         #a04100;
  --col-done:            #1a7f37;
  --col-problems:        #ba1a1a;

  --priority-low:        #737688;
  --priority-medium:     #003ec7;
  --priority-high:       #a04100;
  --priority-critical:   #ba1a1a;

  --shadow-sm:           0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md:           0 2px 8px rgba(15, 23, 42, 0.10);
  --shadow-lg:           0 8px 24px rgba(15, 23, 42, 0.14);

  --r-sm:                2px;
  --r-md:                4px;
  --r-lg:                6px;

  --font-sans:           'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:           'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg:                  #0f1115;
  --bg-grid:             #1e2024;
  --surface:             #1a1c20;
  --surface-alt:         #1e2024;
  --surface-high:        #282a2e;
  --text:                #e2e2e8;
  --text-muted:          #c3c5d9;
  --text-faint:          #8d90a2;
  --border:              #434656;
  --border-strong:       #8d90a2;

  --primary:             #b7c4ff;
  --primary-hover:       #dfe3ff;
  --primary-soft:        rgba(183, 196, 255, 0.16);
  --secondary:           #ffb693;
  --secondary-soft:      rgba(255, 182, 147, 0.18);
  --tertiary:            #00dbe9;
  --success:             #6ee7a8;
  --warn:                #ffb693;
  --danger:              #ffb4ab;
  --danger-soft:         rgba(255, 180, 171, 0.18);

  --col-backlog:         #8d90a2;
  --col-progress:        #b7c4ff;
  --col-review:          #c4b5fd;
  --col-testing:         #ffb693;
  --col-done:            #6ee7a8;
  --col-problems:        #ffb4ab;

  --priority-low:        #8d90a2;
  --priority-medium:     #b7c4ff;
  --priority-high:       #ffb693;
  --priority-critical:   #ffb4ab;

  /* В dark theme плашки tonal/светлые — текст должен быть тёмным, иначе нечитаемо. */
  --on-tint:             #0f1115;
  --accent:              #b7c4ff;

  --shadow-sm:           0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md:           0 2px 8px rgba(0, 0, 0, 0.6);
  --shadow-lg:           0 8px 24px rgba(0, 0, 0, 0.7);
}

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  background-image: radial-gradient(var(--bg-grid) 0.5px, transparent 0.5px);
  background-size: 32px 32px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Утилитарный mono-label ── */
.label, .column-head, .priority-badge, .label-pill,
.tab, .metric-label, .checklist-head, .badge,
.bycol-item, .source-github {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ── Шапка ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-left  { display: flex; align-items: center; gap: 28px; }
.header-right { display: flex; gap: 8px; align-items: center; }

.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
  text-transform: uppercase;
  color: var(--primary);
}
.app-header h1::before {
  content: '▮';
  color: var(--secondary);
  margin-right: 8px;
}

/* ── Табы ── */
.tabs { display: flex; gap: 0; }
.tab {
  background: transparent;
  border: 1px solid var(--border);
  border-right-width: 0;
  padding: 7px 16px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-radius: 0;
}
.tab:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.tab:last-child  { border-radius: 0 var(--r-md) var(--r-md) 0; border-right-width: 1px; }
.tab:hover       { background: var(--surface-alt); color: var(--text); }
.tab.active      { background: var(--primary); color: var(--on-tint); border-color: var(--primary); }

/* ── Кнопки ── */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-sans);
  font-weight: 600;
  border-radius: var(--r-md);
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-alt); border-color: var(--border-strong); }

.btn-primary {
  background: var(--primary);
  color: var(--on-tint);
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-tint); }

.btn-secondary { background: var(--surface-alt); }
.btn-secondary:hover { background: var(--surface-high); }

.btn-danger { background: var(--danger); color: var(--on-tint); border-color: var(--danger); }
.btn-danger:hover { background: #8b0d0d; border-color: #8b0d0d; color: #fff; }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-alt); border-color: var(--border); }

.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
}

/* ── Фильтры ── */
.filters {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.filters select, .filters input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  transition: border-color 0.12s;
}
.filters select:focus, .filters input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Виды/секции ── */
.view { display: none; padding: 20px 24px; }
.view-active { display: block; }

/* ── Канбан ── */
.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 12px;
  align-items: flex-start;
}
.column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
  overflow: hidden;
}
.column-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.column-head .count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 8px;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
  font-family: var(--font-mono);
}

/* верхняя цветная полоса под названием колонки */
.column[data-name="Backlog"]     { border-top: 3px solid var(--col-backlog); }
.column[data-name="In Progress"] { border-top: 3px solid var(--col-progress); }
.column[data-name="Code Review"] { border-top: 3px solid var(--col-review); }
.column[data-name="Testing"]     { border-top: 3px solid var(--col-testing); }
.column[data-name="Done"]        { border-top: 3px solid var(--col-done); }
.column[data-name="Problems"]    { border-top: 3px solid var(--col-problems); }

.column-body {
  padding: 8px;
  flex: 1;
  overflow-y: auto;
  min-height: 80px;
}
.column-body.drag-over {
  background: var(--primary-soft);
  outline: 1px dashed var(--primary);
  outline-offset: -4px;
}

/* ── Карточка задачи ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
.card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.card.dragging { opacity: 0.4; }

/* Полоска возраста слева: <3 дней — зелёный, 3–7 — жёлтый, >7 — красный.
   inset box-shadow не меняет геометрию, поэтому border и layout не страдают. */
.card.age-fresh { box-shadow: inset 4px 0 0 var(--success), var(--shadow-sm); }
.card.age-warn  { box-shadow: inset 4px 0 0 #eab308,        var(--shadow-sm); }
.card.age-stale { box-shadow: inset 4px 0 0 var(--danger),  var(--shadow-sm); }
.card.age-fresh:hover { box-shadow: inset 4px 0 0 var(--success), var(--shadow-md); }
.card.age-warn:hover  { box-shadow: inset 4px 0 0 #eab308,        var(--shadow-md); }
.card.age-stale:hover { box-shadow: inset 4px 0 0 var(--danger),  var(--shadow-md); }

.card-stamp {
  margin-left: auto;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 10px;
  white-space: nowrap;
}

.card-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  line-height: 1.3;
  color: var(--text);
  padding-right: 36px; /* резерв под absolute .card-pdf-btn (26px + 6px right + воздух) — заголовок не затекает под 📄 */
}
.card-meta {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.priority-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-size: 10px;
  color: var(--on-tint);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.priority-low      { background: var(--priority-low); }
.priority-medium   { background: var(--priority-medium); }
.priority-high     { background: var(--priority-high); }
.priority-critical { background: var(--priority-critical); }

.label-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid transparent;
}
.label-pill.bug        { background: var(--danger-soft); color: var(--danger); }
.label-pill.feature    { background: rgba(26, 127, 55, 0.15); color: var(--success); }
.label-pill.regression { background: var(--secondary-soft); color: var(--secondary); }

.card .pr-link {
  font-size: 10px;
  color: var(--primary);
  text-decoration: none;
  font-family: var(--font-mono);
  border-bottom: 1px dashed var(--primary);
}
.card .pr-link:hover { color: var(--primary-hover); }
.card .source-github {
  font-size: 9px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Главная: карточки проектов ── */
.projects-wrap {
  padding: 24px 32px;
}
.projects-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.projects-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.project-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.project-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.project-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  word-break: break-word;
}
.project-card-repo {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  word-break: break-all;
}
.project-card-role {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
}
.project-card-role.role-owner     { background: var(--primary-soft); color: var(--primary); }
.project-card-role.role-developer { background: var(--surface-alt); color: var(--text-muted); }
.project-card-role.role-qa        { background: rgba(254, 107, 0, 0.15); color: var(--secondary); }
.project-card-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.project-card-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.project-card-count b { color: var(--text); font-weight: 700; }
.project-card-count.count-backlog  { border-left: 3px solid var(--col-backlog); }
.project-card-count.count-progress { border-left: 3px solid var(--col-progress); }
.project-card-count.count-review   { border-left: 3px solid var(--col-review); }
.project-card-count.count-problems { border-left: 3px solid var(--col-problems); }
.project-card-count.count-testing  { border-left: 3px solid var(--col-testing); }
.project-card-count.count-done     { border-left: 3px solid var(--col-done); }
.project-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.projects-empty {
  grid-column: 1 / -1;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Меню действий на карточке проекта (⋮) */
.project-card-menu {
  position: relative;
  flex-shrink: 0;
}
.project-card-menu-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: var(--r-sm);
}
.project-card-menu-btn:hover { background: var(--surface-alt); color: var(--text); }
.project-card-menu-list {
  position: absolute;
  top: 100%; right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
  z-index: 10;
}
.project-card-menu-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: var(--r-sm);
}
.project-card-menu-list button:hover { background: var(--surface-alt); }
.project-card-menu-list button.danger { color: var(--danger); }
.project-card.archived {
  opacity: 0.78;
  border-style: dashed;
}
.project-card-archived-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* 💀 Модалка удаления проекта */
.modal-skull {
  max-width: 480px;
  padding: 28px 32px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--danger);
  border-radius: var(--r-lg);
  box-shadow: 0 0 0 1px var(--danger-soft), var(--shadow-lg);
}
.skull-emoji {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 12px;
  animation: skull-shake 1.2s ease-in-out infinite;
}
@keyframes skull-shake {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-8deg); }
  75%      { transform: rotate(8deg); }
}
.skull-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--danger);
  margin: 0 0 8px;
}
.skull-name {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  margin: 0 0 12px;
  word-break: break-word;
}
.skull-warn {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 20px;
}
.skull-counter {
  margin-bottom: 24px;
}
.skull-counter-bar {
  height: 8px;
  background: var(--surface-alt);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}
.skull-counter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--danger), #ff6347);
  transition: width 0.2s ease-out;
}
.skull-counter-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.skull-counter-text b { color: var(--danger); font-size: 14px; }
.skull-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}
.skull-actions .btn-danger:hover {
  transform: scale(1.05);
  transition: transform 0.1s;
}

/* ── Дашборд ── */
.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--primary);
}
.metric-wide { grid-column: span 3; }
.metric-wide::before { background: var(--secondary); }
.metric-label {
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
}
.metric-value {
  font-size: 40px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
}

.bycol { display: flex; gap: 12px; flex-wrap: wrap; }
.bycol-item {
  padding: 8px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
}
.bycol-item .n {
  font-weight: 700;
  margin-left: 8px;
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ── Модалка ── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 17, 21, 0.6);
  backdrop-filter: blur(2px);
}
.modal-window {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 720px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transition: width 0.18s ease;
}

/* Модалка задачи — можно растягивать (правый-нижний угол). */
#modal-task-window {
  width: 760px;
  height: 88vh;
  min-width: 460px;
  min-height: 360px;
  max-width: 98vw;
  max-height: 96vh;
  resize: both;
  overflow: hidden;
  transition: none;
}
/* Визуальная подсказка-уголок «можно тянуть» поверх нативной ручки браузера. */
#modal-task-window::after {
  content: '';
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 12px;
  height: 12px;
  pointer-events: none;
  background:
    linear-gradient(135deg, transparent 55%, var(--border-strong) 55%, var(--border-strong) 65%, transparent 65%, transparent 75%, var(--border-strong) 75%, var(--border-strong) 85%, transparent 85%);
  opacity: 0.7;
}
/* В режиме whiteboard собственный размер; ручку прячем, чтобы не путала. */
#modal-task-window[data-mode="whiteboard"] {
  resize: none;
}
#modal-task-window[data-mode="whiteboard"]::after { display: none; }

/* Кастомная ручка resize для whiteboard mode — нативная resize-corner браузера
   не работает: drawio iframe перехватывает mousedown в правом-нижнем углу. */
.wb-resize-handle {
  display: none;
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 5;
  background:
    linear-gradient(135deg, transparent 50%, var(--border-strong) 50%, var(--border-strong) 60%, transparent 60%, transparent 72%, var(--border-strong) 72%, var(--border-strong) 82%, transparent 82%);
  opacity: 0.7;
}
.wb-resize-handle:hover { opacity: 1; }
#modal-task-window[data-mode="whiteboard"] .wb-resize-handle { display: block; }
/* Во время drag — iframe не должен ловить mouse, текст не выделяется. */
#modal-task-window.is-resizing { user-select: none; }
#modal-task-window.is-resizing iframe { pointer-events: none; }

/* Whiteboard pane */
.wb-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-alt);
  position: relative;
}
.wb-pane iframe {
  flex: 1;
  width: 100%;
  border: 0;
  display: block;
}
.wb-status {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  pointer-events: none;
}
.wb-saved {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--success);
  letter-spacing: 0.05em;
  opacity: 0.9;
  text-transform: uppercase;
}
.error-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--danger);
  white-space: pre-wrap;
}
#ps-routing-rules {
  font-family: var(--font-mono);
  font-size: 12px;
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 10px;
}
.routing-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-size: 10px;
  font-family: var(--font-mono);
  background: var(--surface-alt);
  color: var(--text);
  margin-right: 4px;
}
.routing-src-rule    { color: var(--success); font-weight: 700; }
.routing-src-ai      { color: var(--primary); font-weight: 700; }
.routing-src-default { color: var(--text-faint); font-weight: 700; }
.wb-ai-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex: 0 0 auto;
}
.wb-ai-bar input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}
.wb-ai-bar input:focus {
  outline: none;
  border-color: var(--accent);
}
.wb-ai-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wb-ai-status.err { color: var(--danger); }
.wb-ai-status.ok  { color: var(--success); }

/* Боковая панель AI-анализа доски — поверх iframe справа. */
.wb-analysis {
  position: absolute;
  top: 49px; /* высота wb-ai-bar */
  right: 0;
  bottom: 0;
  width: 380px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 5;
}
.wb-analysis-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.wb-analysis-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text);
}
.wb-analysis-body h2,
.wb-analysis-body h3 {
  margin: 14px 0 6px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.wb-analysis-body h2:first-child,
.wb-analysis-body h3:first-child { margin-top: 0; }
.wb-analysis-body ul { padding-left: 18px; margin: 6px 0; }
.wb-analysis-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-alt);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ─────────── Модалка «Инструкция» ─────────── */
.modal-help-window {
  width: 90vw;
  max-width: 1100px;
  height: 85vh;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.modal-help-window .modal-header h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.04em;
}
.help-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.help-toc {
  width: 240px;
  border-right: 1px solid var(--border);
  padding: 12px 0;
  overflow-y: auto;
  flex-shrink: 0;
  background: var(--surface-alt);
}
.help-toc button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 16px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  transition: background 0.12s ease;
}
.help-toc button:hover {
  background: var(--surface);
}
.help-toc button.active {
  background: var(--surface);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}
.help-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 28px;
  min-width: 0;
}
.help-content article { display: none; }
.help-content article.active { display: block; }
.help-content h2 {
  margin: 0 0 14px;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.help-content h3 {
  margin: 18px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.help-content p {
  margin: 8px 0;
  line-height: 1.55;
  font-size: 13.5px;
}
.help-content ul,
.help-content ol {
  margin: 8px 0;
  padding-left: 22px;
  line-height: 1.55;
  font-size: 13.5px;
}
.help-content li { margin: 4px 0; }
.help-content code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: 3px;
}
.help-content kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--surface-alt);
}
.help-content strong { color: var(--text); }
.help-content em { color: var(--text-muted); font-style: normal; }
.help-callout {
  margin: 14px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-alt);
  font-size: 13px;
  line-height: 1.55;
  border-radius: 0 4px 4px 0;
}
.help-flow {
  counter-reset: help-flow;
  list-style: none;
  padding-left: 0;
}
.help-flow > li {
  position: relative;
  padding: 4px 0 4px 32px;
  counter-increment: help-flow;
}
.help-flow > li::before {
  content: counter(help-flow);
  position: absolute;
  left: 0;
  top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-tint);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Whiteboard режим — модалка растягивается, форма прячется */
.modal-window[data-mode="whiteboard"] {
  width: 95vw;
  max-width: 98vw;
  height: 92vh;
  max-height: 96vh;
}
.modal-window[data-mode="whiteboard"] .modal-body { display: none; }
.modal-window[data-mode="whiteboard"] #wb-pane { display: flex !important; }
.modal-window[data-mode="whiteboard"] #t-delete,
.modal-window[data-mode="whiteboard"] #t-save {
  display: none;
}
:root[data-theme="dark"] .modal-window {
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(183, 196, 255, 0.1);
}
.modal-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 14px;
}
.modal-header h2 {
  margin: 0;
  font-size: 13px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text);
}
.modal-title-tail { color: var(--text-muted); font-size: 12px; }

/* Form / Whiteboard переключалка */
.modal-tabs { display: flex; gap: 0; }
.modal-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-right-width: 0;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-radius: 0;
}
.modal-tab:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.modal-tab:last-child  { border-radius: 0 var(--r-md) var(--r-md) 0; border-right-width: 1px; }
.modal-tab:hover:not(:disabled) { background: var(--surface-alt); color: var(--text); }
.modal-tab.active { background: var(--primary); color: var(--on-tint); border-color: var(--primary); }
.modal-tab:disabled { opacity: 0.5; cursor: not-allowed; }
.modal-close { margin-left: auto; }
.modal-close {
  background: transparent; border: none;
  font-size: 22px; cursor: pointer;
  color: var(--text-muted);
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
}
.modal-close:hover { background: var(--surface-high); color: var(--text); }

/* Кнопка «развернуть на весь экран». margin-left: auto притягивает её и
   следующую за ней .modal-close к правому краю шапки. */
.modal-maximize {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.modal-maximize:hover { background: var(--surface-high); color: var(--text); }

/* Fullscreen для карточки задачи. !important — перебивает базовый
   #modal-task-window, его data-mode="whiteboard" вариант и inline-стили
   от кастомного resize handle. */
#modal-task-window.is-maximized {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  border-radius: 0;
  resize: none;
}
#modal-task-window.is-maximized::after { display: none; }
#modal-task-window.is-maximized .wb-resize-handle { display: none; }

.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-body label {
  display: block;
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.modal-body input[type=text],
.modal-body textarea,
.modal-body select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--surface);
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  transition: border-color 0.12s;
}
.modal-body input[type=text]:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.modal-body textarea { resize: vertical; min-height: 80px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  gap: 8px;
  align-items: center;
}
.modal-footer .spacer { flex: 1; }

/* ── Чек-листы ── */
#checklists-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.section-head h3 {
  margin: 0;
  font-size: 12px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.checklist-add { display: flex; gap: 6px; flex-wrap: wrap; }
.checklist-add select, .checklist-add input {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
}
.checklist {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 12px;
  background: var(--surface-alt);
}
.checklist-head {
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.checklist-head .badge {
  font-size: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 6px;
  color: var(--text-muted);
  font-weight: 700;
}
.checklist-items { padding: 6px; }
.cl-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 4px;
}
.cl-item .cl-status {
  flex: 0 0 auto;
  width: 180px;
}
.cl-item .text { flex: 1; min-width: 0; }
.cl-item.s-passed   { background: rgba(26, 127, 55, 0.10); border-color: rgba(26, 127, 55, 0.4); }
.cl-item.s-failed   { background: var(--danger-soft); border-color: var(--danger); }
.cl-item.s-blocked  { background: var(--secondary-soft); border-color: var(--secondary); }
.cl-item .bug-link {
  font-size: 10px;
  color: var(--danger);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cl-add-row { display: flex; gap: 6px; padding: 6px 8px; }
.cl-add-row input {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

/* ── AI-помощник ── */
#ai-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.ai-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ai-actions select, .ai-actions input {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
}
.ai-output {
  padding: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin: 12px 0;
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 13px;
  max-height: 320px;
  overflow-y: auto;
  font-family: var(--font-sans);
}
.ai-output ul { margin: 4px 0; padding-left: 22px; }
.ai-output li { margin: 4px 0; }
.ai-output .ai-output-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.ai-chat { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ai-messages {
  max-height: 280px;
  overflow-y: auto;
  padding: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-height: 60px;
}
.ai-messages:empty::before {
  content: '// CLAUDE_CHAT :: WAITING_FOR_INPUT';
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.ai-msg {
  padding: 9px 12px;
  margin-bottom: 6px;
  border-radius: var(--r-sm);
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 13px;
  border: 1px solid var(--border);
}
.ai-msg-user      { background: var(--primary-soft); border-color: var(--primary); color: var(--text); }
.ai-msg-assistant { background: var(--surface); }
.ai-msg-error     { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.ai-input { display: flex; gap: 6px; }
.ai-input textarea {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  resize: vertical;
  font-family: var(--font-sans);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  min-height: 50px;
}
.ai-input textarea:focus { outline: none; border-color: var(--primary); }

.cl-item .ai-bug-btn {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cl-item .ai-bug-btn:hover { background: var(--danger); color: var(--on-tint); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-strong);
}
.toast.error { background: var(--danger); color: var(--on-tint); border-color: var(--danger); }
.toast.ok    { background: var(--success); color: var(--on-tint); border-color: var(--success); }

/* ── Login & user-info ── */
.user-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.user-role {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 6px;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--primary);
}
.modal-login-window { width: 420px; }
.login-error {
  margin: 8px 0;
  padding: 8px 10px;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--r-md);
  font-size: 13px;
}
.login-hint {
  margin: 14px 0 0;
  padding: 10px;
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.login-hint code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Project selector */
.project-bar {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}
#project-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}

/* Project Settings */
.settings-wrap { max-width: 720px; margin: 0 auto; }
.settings-h {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 14px;
  margin: 24px 0 12px;
}
.settings-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.settings-hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.copy-row { display: flex; gap: 6px; margin-top: 4px; }
.copy-row input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}
.settings-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.settings-hint code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 11px;
}
#view-settings label {
  display: block;
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
#view-settings input[type=text] {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--surface);
  text-transform: none;
  letter-spacing: normal;
}

.hidden { display: none !important; }

/* ── AI-детектор дубликатов ── */
.dup-suggestions {
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: var(--r-md);
}
.dup-head {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 12px;
  font-weight: 700; color: var(--primary);
  margin-bottom: 6px;
}
.dup-head .btn-mini { margin-left: auto; }
.dup-item {
  padding: 6px 8px; border-radius: var(--r-sm);
  background: var(--surface);
  margin-bottom: 4px;
}
.dup-item:last-child { margin-bottom: 0; }
.dup-line { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.dup-open { color: var(--primary); text-decoration: none; font-weight: 600; }
.dup-open:hover { text-decoration: underline; }
.dup-meta { margin-left: auto; color: var(--text-muted); font-family: var(--font-mono); font-size: 11px; }
.dup-reason { color: var(--text-muted); font-size: 12px; margin-top: 3px; font-style: italic; }
.dup-empty { font-size: 13px; color: var(--text-muted); padding: 4px 8px; }

/* ── Welcome tour ── */
.tour-overlay {
  position: fixed; inset: 0; z-index: 5000;
  pointer-events: none;
  display: none;
}
.tour-overlay.is-active { display: block; }
.tour-cutout {
  position: absolute;
  border: 2px solid var(--primary);
  border-radius: var(--r-md);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55);
  transition: top .25s, left .25s, width .25s, height .25s;
  pointer-events: none;
}
.tour-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: var(--r-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  transition: top .25s, left .25s;
}
.tour-step-num { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.tour-title { font-size: 16px; font-weight: 700; color: var(--text); margin: 4px 0 6px; }
.tour-body  { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.tour-buttons { margin-top: 12px; display: flex; gap: 8px; justify-content: flex-end; }
.tour-buttons .btn { padding: 5px 12px; font-size: 12px; }
body.tour-running { overflow: hidden; }

/* ── Severity badge на карточке ── */
.severity-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  color: var(--on-tint);
}
.severity-badge.sev-blocker  { background: #6b0d0d; }
.severity-badge.sev-critical { background: var(--danger); }
.severity-badge.sev-major    { background: var(--warn); }
.severity-badge.sev-minor    { background: var(--text-muted); }
.severity-badge.sev-trivial  { background: var(--text-faint); }

/* ── Dashboard charts ── */
.chart { width: 100%; min-height: 180px; position: relative; }
.chart-svg { display: block; }
.chart-line { stroke: var(--primary); stroke-width: 2; fill: none; }
.chart-area { fill: var(--primary); opacity: 0.12; }
.chart-dot  { fill: var(--primary); }
.chart-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.6; }
.chart-tick { font-family: var(--font-mono); font-size: 10px; fill: var(--text-faint); }
.chart-caption { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin-top: 6px; }
.chart-empty   { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); padding: 28px 0; text-align: center; }

.severity-bars { display: flex; flex-direction: column; gap: 6px; padding: 6px 4px; }
.sev-row { display: grid; grid-template-columns: 70px 1fr 40px; gap: 8px; align-items: center; font-size: 12px; }
.sev-label { font-family: var(--font-mono); font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.sev-label.sev-blocker  { color: #6b0d0d; }
.sev-label.sev-critical { color: var(--danger); }
.sev-label.sev-major    { color: var(--warn); }
.sev-label.sev-minor    { color: var(--text-muted); }
.sev-label.sev-trivial  { color: var(--text-faint); }
.sev-bar { height: 12px; background: var(--surface-alt); border-radius: var(--r-sm); overflow: hidden; }
.sev-bar-fill { display: block; height: 100%; }
.sev-bar-fill.sev-blocker  { background: #6b0d0d; }
.sev-bar-fill.sev-critical { background: var(--danger); }
.sev-bar-fill.sev-major    { background: var(--warn); }
.sev-bar-fill.sev-minor    { background: var(--text-muted); }
.sev-bar-fill.sev-trivial  { background: var(--text-faint); }
.sev-count { text-align: right; font-family: var(--font-mono); color: var(--text-muted); }

/* ── Комментарии к задаче ── */
#comments-section { margin-top: 18px; }
.comments-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; max-height: 360px; overflow-y: auto; }
.comments-list:empty { display: none; }
.comment-item {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 10px;
}
.comment-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-muted);
  margin-bottom: 4px;
  font-family: var(--font-mono);
}
.comment-author { font-weight: 700; color: var(--text); }
.comment-time   { color: var(--text-faint); }
.comment-edited { color: var(--text-faint); font-style: italic; }
.comment-actions { margin-left: auto; display: flex; gap: 4px; }
.btn-mini {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  padding: 0 6px; font-size: 11px; line-height: 18px;
  border-radius: var(--r-sm);
}
.btn-mini:hover { background: var(--surface-high); color: var(--text); }
.comment-body { white-space: pre-wrap; word-wrap: break-word; font-size: 13px; color: var(--text); }

.comment-form { display: flex; gap: 8px; }
.comment-form textarea {
  flex: 1; resize: vertical; min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
}

/* ── История изменений ── */
#history-section { margin-top: 12px; }
.section-head-collapsible { cursor: pointer; user-select: none; }
.section-head-collapsible:hover h3 { color: var(--primary); }
.section-head-collapsible .caret { font-family: var(--font-mono); color: var(--text-muted); margin-left: auto; }
.history-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; font-size: 12px; }
.history-item {
  display: flex; gap: 10px; padding: 4px 8px;
  border-left: 2px solid var(--border);
}
.history-time { color: var(--text-faint); font-family: var(--font-mono); font-size: 11px; min-width: 110px; }
.history-text { color: var(--text-muted); }

/* ── Глобальный поиск задач ── */
.task-search-overlay { position: fixed; inset: 0; z-index: 1000; }
.task-search-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}
.task-search-window {
  position: absolute; top: 10vh; left: 50%; transform: translateX(-50%);
  width: min(680px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
#task-search-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-alt);
  color: var(--text);
  outline: none;
}
#task-search-input:focus { border-color: var(--primary); }
.task-search-results { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.task-search-item {
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  background: var(--surface);
}
.task-search-item:hover, .task-search-item.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.tsi-title { font-size: 14px; color: var(--text); }
.tsi-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 10px; align-items: center; margin-top: 3px; font-family: var(--font-mono); }
.task-search-empty {
  text-align: center; padding: 20px; color: var(--text-muted);
  font-family: var(--font-mono); font-size: 13px;
}
.task-search-hint {
  color: var(--text-faint); font-size: 11px;
  font-family: var(--font-mono);
  text-align: center;
}

/* ── Пароль с глазиком ── */
.pwd-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.pwd-row input[type=password],
.pwd-row input[type=text] {
  flex: 1;
}
.pwd-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 0 10px;
  border-radius: var(--r-md);
  font-size: 16px;
  line-height: 1;
  min-width: 38px;
}
.pwd-toggle:hover { background: var(--surface-alt); }
.pwd-toggle.active {
  background: var(--primary-soft);
  border-color: var(--primary);
}

/* ── Админ-панель ── */
.admin-wrap { display: flex; flex-direction: column; gap: 16px; }
.admin-subtabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.admin-subtab {
  background: transparent;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 8px 16px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-radius: var(--r-md) var(--r-md) 0 0;
  margin-bottom: -1px;
}
.admin-subtab.active {
  background: var(--surface);
  color: var(--primary);
  border-bottom: 1px solid var(--surface);
  font-weight: 700;
}
.admin-subtab:hover:not(.active) { background: var(--surface-alt); color: var(--text); }

.admin-pane { display: none; }
.admin-pane.active { display: block; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table th {
  background: var(--surface-alt);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--surface-alt); }
.admin-table .nowrap { white-space: nowrap; color: var(--text-muted); font-family: var(--font-mono); font-size: 11px; }
.admin-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-table .actions .btn { padding: 4px 8px; font-size: 11px; }
.admin-role-admin { color: var(--secondary); font-weight: 700; font-family: var(--font-mono); }
.admin-role-user  { color: var(--text-muted); font-family: var(--font-mono); }
.role-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.role-select:focus { outline: none; border-color: var(--primary); }
.admin-event-login_fail  { color: var(--danger);  font-family: var(--font-mono); font-weight: 700; }
.admin-event-signup_fail { color: var(--warn);    font-family: var(--font-mono); font-weight: 700; }
.admin-event-login_ok    { color: var(--success); font-family: var(--font-mono); }
.admin-event-signup_ok   { color: var(--primary); font-family: var(--font-mono); }

.admin-audit-filters {
  display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.admin-audit-filters select,
.admin-audit-filters input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}
.admin-audit-filters input { flex: 1; max-width: 320px; }

.members-add-row {
  display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap;
  align-items: center;
}
.members-add-row input[type=email] {
  flex: 1; min-width: 240px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}
.members-add-row select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

.admin-ua {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

/* ── Вложения ── */
#attachments-section { margin-top: 18px; }
#attachments-section .section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 8px;
}
#attachments-section .section-head h3 {
  margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-family: var(--font-mono);
}
.att-list {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px;
}
.att-list:empty { display: none; }
.att-thumb {
  position: relative;
  width: 96px; height: 96px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-alt);
  display: flex; flex-direction: column;
}
.att-thumb a.att-link {
  display: flex; flex: 1; align-items: center; justify-content: center;
  text-decoration: none; color: var(--text);
  overflow: hidden;
}
.att-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.att-pdf-icon {
  font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--text);
  background: var(--surface);
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
}
.att-pdf-icon .att-pdf-ext { font-size: 18px; }
.att-name {
  font-size: 11px;
  padding: 3px 6px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.att-del {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px;
  border: none; cursor: pointer; padding: 0;
  background: rgba(0,0,0,0.55); color: #fff;
  border-radius: 50%;
  font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.att-del:hover { background: rgba(220, 38, 38, 0.9); }
.att-thumb.pending { opacity: 0.6; border-style: dashed; }
.att-thumb.uploading { opacity: 0.5; pointer-events: none; }
.att-hint {
  font-size: 11px; color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Скроллбары (только Webkit) ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface-alt); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }


/* ─────────── KPI сотрудников/тестировщиков ─────────── */
.kpi-wrap { padding: 16px 24px 28px; }
.kpi-toolbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.kpi-field {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
}
.kpi-field select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  text-transform: none; letter-spacing: 0;
  cursor: pointer;
}
.kpi-field select:focus { outline: none; border-color: var(--primary); }
.kpi-hint {
  font-size: 11px; color: var(--text-faint); font-family: var(--font-mono);
  flex: 1; min-width: 200px;
}
.kpi-team-table tbody tr[data-uid] { cursor: pointer; }
.kpi-team-table tbody tr.kpi-row-active td { background: var(--primary-soft, rgba(0, 62, 199, 0.10)); }
.kpi-team-table th.kpi-num, .kpi-num { text-align: right; font-family: var(--font-mono); }
.kpi-empty { text-align: center; color: var(--text-faint); font-family: var(--font-mono); padding: 18px 0; }
.kpi-detail { margin-top: 24px; }
.kpi-detail.hidden { display: none; }
.kpi-detail-name {
  margin: 0 0 12px 0; font-size: 18px; font-weight: 700; color: var(--text);
}
.kpi-byproject { width: 100%; overflow-x: auto; }
.kpi-byproject-table { margin: 0; }
.kpi-byproject-table th, .kpi-byproject-table td { font-size: 12px; }


/* ─────────── Invite landing page ─────────── */

/* В режиме инвайта прячем основную хедер-навигацию и все view, кроме view-invite. */
body.is-invite-mode > .app-header,
body.is-invite-mode > .filters,
body.is-invite-mode > #view-board,
body.is-invite-mode > #view-dashboard,
body.is-invite-mode > #view-settings,
body.is-invite-mode > #view-admin {
  display: none !important;
}
body.is-invite-mode #view-invite {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.invite-wrap { width: 100%; max-width: 480px; }
.invite-card, .invite-error {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}
.invite-title {
  margin: 0 0 16px 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.invite-line { margin: 8px 0; color: var(--text); font-size: 14px; }
.invite-meta { color: var(--text-muted); font-size: 12px; font-family: var(--font-mono); }
.invite-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: var(--on-tint);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.invite-accept {
  margin-top: 20px;
  width: 100%;
  padding: 12px;
  font-size: 14px;
}
.invite-hint {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

/* ─────────── Invites table + GH events table в Settings ─────────── */

.invites-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0 16px 0;
  flex-wrap: wrap;
}
.invites-add-row select,
.invites-add-row input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}
.invites-add-row input[type="email"] { flex: 1; min-width: 200px; }
.invites-add-row input[type="number"] { width: 70px; }
.invite-link {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
}
.invite-link:hover { text-decoration: underline; }
.badge-ok    { background: rgba(26, 127, 55, 0.18); color: var(--success); }
.badge-warn  { background: var(--secondary-soft);   color: var(--secondary); }

.gh-event-pre {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px;
  max-height: 60vh;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}


/* ─────────── Видимая индикация активного проекта в шапке ─────────── */
.project-bar-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-right: 2px;
}
.project-select-badge {
  font-size: 14px;
  font-weight: 700;
  padding: 6px 12px;
  border: 2px solid var(--primary);
  border-radius: var(--r-md);
  background: var(--primary-soft, rgba(0, 62, 199, 0.08));
  color: var(--primary);
  cursor: pointer;
  min-width: 200px;
  max-width: 320px;
  text-overflow: ellipsis;
}
.project-select-badge:hover { background: var(--primary-soft, rgba(0, 62, 199, 0.14)); }
.project-select-badge:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 62, 199, 0.2);
}
:root[data-theme="dark"] .project-select-badge {
  background: rgba(127, 156, 255, 0.08);
  color: #aac0ff;
  border-color: #6a8aff;
}
:root[data-theme="dark"] .project-select-badge:hover {
  background: rgba(127, 156, 255, 0.16);
}


/* ─────────── Workspace переключатель (dual-mode) ─────────── */
.workspace-tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px 12px 24px;
  margin: 0;
  border-bottom: 1px solid var(--border);
}
.workspace-tabs.hidden { display: none; }
.workspace-tab {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--r-md) var(--r-md) 0 0;
  padding: 8px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  bottom: -1px;
}
.workspace-tab:hover {
  background: var(--surface-alt);
  color: var(--text);
}
.workspace-tab.active {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--primary);
  border-bottom: 1px solid var(--surface);
}
:root[data-theme="dark"] .workspace-tab.active {
  color: #aac0ff;
  border-color: #6a8aff;
}


/* ─────────── Вложения в комментариях ─────────── */
.comment-paste-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}
.comment-paste-files:empty { display: none; }
.comment-att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 11px;
  font-family: var(--font-mono);
  max-width: 220px;
}
.comment-att-chip img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 2px;
}
.comment-att-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.comment-att-chip button {
  appearance: none;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  padding: 0 2px;
}
.comment-att-chip button:hover { color: var(--danger); }
.comment-actions-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}
/* Список вложений в уже опубликованных комментариях */
.comment-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.comment-attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 11px;
  font-family: var(--font-mono);
  text-decoration: none;
  color: var(--text);
}
.comment-attachment-link img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 2px;
  cursor: zoom-in;
}
.comment-attachment-link:hover { background: var(--surface-high); }


/* Памятка маппинга в Settings → Режим доски */
.workspace-mode-hint {
  margin: 8px 0 12px 0;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.workspace-mode-hint summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  padding: 4px 0;
}
.ws-map-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 12px;
}
.ws-map-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.ws-map-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.ws-map-table tr:last-child td { border-bottom: none; }
.ws-map-table td:first-child { width: 45%; }


/* Кнопки действий на карточках (dual-mode переходы между QA/Dev) */
.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.card-action {
  appearance: none;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
}
.card-action:hover { background: var(--surface-high); }
.card-action-primary {
  background: rgba(26, 127, 55, 0.14);
  color: var(--success);
  border-color: rgba(26, 127, 55, 0.4);
}
.card-action-primary:hover { background: rgba(26, 127, 55, 0.24); }
.card-action-secondary {
  background: var(--secondary-soft);
  color: var(--secondary);
  border-color: var(--secondary);
}
.card-action-secondary:hover { background: rgba(213, 124, 0, 0.24); }


/* Состояние "уже отправлено в Dev" — серая, без действия */
.card-action-sent {
  background: var(--surface-high, rgba(0,0,0,0.06));
  color: var(--text-muted);
  border-color: var(--border);
  cursor: default;
}
.card-action-sent:hover { background: var(--surface-high, rgba(0,0,0,0.06)); }


/* ─────────── Пространство Заметки: стикеры + чат ─────────── */
.notes-view {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 12px;
  height: calc(100vh - 200px);
  min-height: 480px;
  padding: 0 16px 16px;
}
.notes-view.hidden { display: none; }
.notes-canvas-wrap {
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.notes-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  flex-wrap: wrap;
}
.notes-color-row { display: flex; gap: 4px; }
.note-color-pick {
  width: 22px; height: 22px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
}
.note-color-pick.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary) inset;
}
.notes-hint { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.notes-canvas {
  position: relative;
  flex: 1;
  overflow: auto;
  background:
    linear-gradient(var(--border) 1px, transparent 1px) 0 0/24px 24px,
    linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0/24px 24px,
    var(--surface);
  background-blend-mode: soft-light;
}
.sticker {
  position: absolute;
  min-width: 120px; min-height: 80px;
  padding: 10px 12px;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  cursor: move;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  color: #1a1a1a;
  user-select: text;
  display: flex; flex-direction: column;
}
.sticker.color-yellow { background: #ffeb8a; }
.sticker.color-pink   { background: #ffc8d8; }
.sticker.color-blue   { background: #b8d8ff; }
.sticker.color-green  { background: #bff0c4; }
.sticker.color-orange { background: #ffd0a0; }
.sticker.color-purple { background: #d8c8ff; }
.sticker.color-gray   { background: #d8d8d8; }
.sticker.dragging { opacity: 0.85; box-shadow: 0 8px 24px rgba(0,0,0,0.28); }
.sticker-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; color: rgba(0,0,0,0.55);
  font-family: var(--font-mono);
  margin-bottom: 4px;
}
.sticker-author { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sticker-actions { display: flex; gap: 2px; flex-shrink: 0; }
.sticker-actions button {
  background: rgba(0,0,0,0.08);
  border: none;
  width: 18px; height: 18px;
  padding: 0;
  font-size: 11px;
  cursor: pointer;
  color: #333;
  border-radius: 3px;
}
.sticker-actions button:hover { background: rgba(0,0,0,0.18); }
.sticker-body {
  flex: 1;
  white-space: pre-wrap;
  word-wrap: break-word;
  outline: none;
  overflow: auto;
}
.sticker-body[contenteditable="true"] {
  background: rgba(255,255,255,0.5);
  cursor: text;
}

/* Чат-панель */
.notes-chat {
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.notes-chat-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  background: var(--surface-alt);
}
.notes-chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex; flex-direction: column;
  gap: 8px;
}
.chat-msg {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  font-size: 13px;
}
.chat-msg-head {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 2px;
}
.chat-msg-author { font-weight: 700; color: var(--text); }
.chat-msg-body { white-space: pre-wrap; word-wrap: break-word; }
.chat-msg-del {
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  font-size: 12px; padding: 0 2px;
  margin-left: 4px;
}
.chat-msg-del:hover { color: var(--danger); }
.notes-chat-form {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
}
#notes-chat-input {
  resize: none;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}


/* ─────────── Rich-text editor для поля Описание ─────────── */
.rich-editor-label { display: block; }
.rich-editor-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: var(--surface-alt);
}
.rich-editor-toolbar button,
.rich-editor-toolbar .rich-color-pick {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
}
.rich-editor-toolbar button:hover,
.rich-editor-toolbar .rich-color-pick:hover { background: var(--border); }
.rich-editor-toolbar button.active { background: var(--primary); color: #fff; }
.rich-editor-toolbar .rich-sep {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 4px;
}
.rich-color-pick {
  position: relative;
}
.rich-color-pick input[type="color"] {
  position: absolute; inset: 0;
  opacity: 0;
  cursor: pointer;
  border: none; padding: 0;
}
.rich-color-pick span { pointer-events: none; }

.rich-editor {
  min-height: 120px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.rich-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.rich-editor[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}
.rich-editor ul, .rich-editor ol { margin: 4px 0; padding-left: 24px; }
.rich-editor li { margin: 2px 0; }
.rich-editor p { margin: 4px 0; }
.rich-editor img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 6px 0;
  border-radius: 4px;
}
.rich-editor a { color: var(--primary); text-decoration: underline; }


/* ─────────── Инлайн-редактор комментария ─────────── */
.comment-edit-box {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 4px;
}
.comment-edit-area {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--primary);
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  box-sizing: border-box;
}
.comment-edit-area:focus { outline: none; box-shadow: 0 0 0 1px var(--primary) inset; }
.comment-edit-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.comment-edit-hint {
  font-size: 11px; color: var(--text-muted);
  font-family: var(--font-mono);
  margin-left: auto;
}


/* ─────────── Кнопка скачивания картинок в описании ─────────── */
.img-download-overlay {
  position: fixed;
  z-index: 10000;
  width: 30px; height: 30px;
  padding: 0;
  background: rgba(0,0,0,0.75);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: background 0.12s, transform 0.12s;
}
.img-download-overlay:hover {
  background: var(--primary);
  transform: scale(1.08);
}
.rich-editor img { cursor: zoom-in; }


/* ─────────── Кнопка PDF на карточке доски ─────────── */
.card { position: relative; }
.card-pdf-btn {
  position: absolute;
  top: 6px; right: 6px;
  width: 26px; height: 26px;
  padding: 0;
  background: rgba(0,0,0,0.42);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  opacity: 0.5;
  pointer-events: auto;
  transition: opacity 0.15s, background 0.15s, transform 0.12s;
  display: flex; align-items: center; justify-content: center;
  z-index: 3;
}
.card:hover .card-pdf-btn,
.card:focus-within .card-pdf-btn { opacity: 1; }
.card-pdf-btn:hover { background: var(--primary); transform: scale(1.06); }
.card-pdf-btn:focus { outline: 2px solid var(--primary); opacity: 1; }


/* ─────────── Кнопка PDF в шапке колонки ─────────── */
.column-head { display: flex; align-items: center; gap: 6px; }
.column-head .count { margin-left: auto; }
.col-pdf-btn {
  margin-left: 4px;
  width: 24px; height: 24px;
  padding: 0;
  background: rgba(0,0,0,0.35);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s, transform 0.12s;
  display: flex; align-items: center; justify-content: center;
}
.col-pdf-btn:hover { opacity: 1; background: var(--primary); transform: scale(1.08); }
.col-pdf-btn:focus { outline: 2px solid var(--primary); opacity: 1; }


/* ─────────── Индикаторы drag-drop reorder ─────────── */
.card.drop-before { position: relative; }
.card.drop-before::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: -5px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--primary);
  pointer-events: none;
}
.column-body.drop-append { position: relative; }
.column-body.drop-append::after {
  content: '';
  position: absolute;
  left: 8px; right: 8px;
  bottom: 4px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--primary);
  pointer-events: none;
}
.card.dragging { opacity: 0.45; }


/* ─────────── Индикатор «обновлено» на карточке ─────────── */
.card.card-changed {
  box-shadow: 0 0 0 2px var(--primary), 0 2px 6px rgba(0,0,0,0.18);
}
.card-changed-badge {
  display: inline-block;
  background: #10b981;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  line-height: 1.2;
  letter-spacing: 0.3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  margin: 0 0 6px 0;
  animation: card-changed-blink 1.1s ease-in-out infinite;
  transition: transform 0.12s, background 0.15s;
}
.card-changed-badge:hover {
  background: #059669;
  transform: scale(1.06);
  animation-play-state: paused;
}
@keyframes card-changed-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
/* Зелёная обводка карточки в тон бейджу */
.card.card-changed {
  box-shadow: 0 0 0 2px #10b981, 0 2px 6px rgba(0,0,0,0.18);
}


/* ─────────── Метка «PDF скачан» на кнопках экспорта ─────────── */
.card-pdf-btn,
.col-pdf-btn { position: relative; }
.card-pdf-btn.downloaded,
.col-pdf-btn.downloaded {
  background: rgba(16, 185, 129, 0.55);
  border-color: rgba(16, 185, 129, 0.8);
}
.card-pdf-btn.downloaded::after,
.col-pdf-btn.downloaded::after {
  content: '✓';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  background: #10b981;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  pointer-events: none;
}
