/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 48px;
  --tabbar-h: 40px;
  --sidebar-bg: #1a1a1a;
  --sidebar-hover: #2a2a2a;
  --sidebar-active: #3a3a3a;
  --tabbar-bg: #252527;
  --tab-active-bg: #1a1a1a;
  --accent: #e07b2f;
  --icon-idle: #636366;
  --icon-active: #ffffff;
  --border: #3a3a3c;
  --card-bg: #ffffff;
  --content-bg: #f2f2f7;
  --text-dark: #1c1c1e;
  --text-mid: #48484a;
  --text-light: #8e8e93;
  --done-color: #34c759;
  --bar-color: #e5e5ea;
  --bar-done: #d1f0db;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body { font-family: var(--font); background: var(--sidebar-bg); overflow: hidden; }

/* ── App Shell ── */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  border-right: 1px solid var(--border);
  z-index: 10;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  background: #000;
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-bottom: 4px;
}

.nav-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--icon-idle);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.nav-btn svg { width: 18px; height: 18px; }

.nav-btn:hover {
  background: var(--sidebar-hover);
  color: var(--icon-active);
}

.nav-btn.active {
  background: var(--sidebar-active);
  color: var(--icon-active);
}

.user-avatar {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(224, 123, 47, 0.15) !important;
}
.user-avatar:hover { background: rgba(224, 123, 47, 0.25) !important; }

/* ── Main area ── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--content-bg);
}

/* ── Tab Bar ── */
.tab-bar {
  height: var(--tabbar-h);
  min-height: var(--tabbar-h);
  background: var(--tabbar-bg);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--icon-idle);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}
.tab:hover { background: #333; color: #ccc; }
.tab.active {
  background: var(--tab-active-bg);
  color: #fff;
  border: 1px solid var(--border);
}

.tab-close {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.5;
  transition: opacity 0.12s;
}
.tab-close:hover { opacity: 1; }

/* ── Page Content ── */
.page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

/* ────────────────────────────────────────────
   DASHBOARD
───────────────────────────────────────────── */
.dashboard-page {
  width: 100%;
  height: 100%;
  position: relative;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.dashboard-bg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.mitridat-logo-box {
  border: 4px solid #000;
  padding: 28px 48px 24px;
  display: inline-block;
  text-align: center;
}

.mitridat-logo-name {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #000;
  line-height: 1;
}

.mitridat-logo-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.mitridat-logo-sub-line {
  flex: 1;
  height: 2px;
  background: #000;
}

.mitridat-logo-sub-text {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 4px;
  color: #000;
  white-space: nowrap;
}

.dashboard-cards {
  display: flex;
  gap: 16px;
  padding: 20px 24px;
  background: rgba(255,255,255,0.92);
  border-top: 1px solid #e5e5ea;
}

.dashboard-card {
  flex: 1;
  background: #fff;
  border: 1px solid #e5e5ea;
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.card-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.card-desc {
  font-size: 12px;
  color: var(--text-mid);
  line-height: 1.5;
}

/* ────────────────────────────────────────────
   СПРАВОЧНИКИ
───────────────────────────────────────────── */
.sprav-page {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--content-bg);
}

.sprav-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 16px;
  background: var(--content-bg);
  border-bottom: 1px solid #e5e5ea;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  padding: 5px 10px;
  width: 220px;
}
.search-box svg { color: var(--text-light); flex-shrink: 0; }
.search-box input {
  border: none;
  outline: none;
  font-size: 12px;
  color: var(--text-dark);
  background: transparent;
  width: 100%;
}

.sprav-sections {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sprav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  color: var(--text-light);
  text-transform: uppercase;
  padding: 14px 0 8px;
  border-top: 1px solid #e5e5ea;
  margin-top: 8px;
}
.sprav-section-label:first-child { margin-top: 0; border-top: none; padding-top: 2px; }

.sprav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  align-content: start;
}

.sprav-grid-dash {
  grid-template-columns: repeat(auto-fill, minmax(200px, 260px));
}

.sprav-card {
  background: #fff;
  border: 1px solid #e5e5ea;
  border-radius: 10px;
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.sprav-card-dash {
  border-color: #fde8d5;
  background: #fff8f4;
  min-height: 90px;
}
.sprav-card-dash:hover { border-color: var(--accent) !important; }
.sprav-card-dash[draggable="true"] { cursor: grab; user-select: none; }
.sprav-card-dash[draggable="true"]:active { cursor: grabbing; }

/* Dashboard webview */
.dash-view { display: flex; flex-direction: column; overflow: hidden; }

.dash-toolbar {
  justify-content: flex-start !important;
  gap: 12px;
  flex-wrap: nowrap;
}

.dash-nav-btns {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.dash-nav-btn {
  border: 1px solid #e5e5ea;
  background: #fff;
  border-radius: 6px;
  width: 26px;
  height: 26px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.dash-nav-btn:hover { background: #f2f2f7; color: var(--text-dark); }

.dash-nav-url {
  font-size: 10px;
  color: var(--text-light);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 6px;
}

.dash-webview {
  flex: 1;
  width: 100%;
  border: none;
}
.sprav-card:hover {
  border-color: #c7c7cc;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.sprav-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-light);
  margin-bottom: 5px;
}

.sprav-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 5px;
  line-height: 1.3;
}

.sprav-desc {
  font-size: 11px;
  color: var(--text-light);
  line-height: 1.4;
}

/* ────────────────────────────────────────────
   РОАДМАП / GANTT
───────────────────────────────────────────── */
:root { --day-w: 80px; --row-h: 36px; --task-col-w: 200px; }

.roadmap-page {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--content-bg);
  position: relative;
}

.roadmap-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--content-bg);
  border-bottom: 1px solid #e5e5ea;
  flex-wrap: wrap;
}

.roadmap-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
  margin-right: 8px;
}

.roadmap-topbar .search-box { width: 180px; }

.roadmap-range-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-mid);
}
.roadmap-range-nav button {
  border: 1px solid #e5e5ea;
  background: #fff;
  border-radius: 6px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-mid);
  display: flex;
  align-items: center;
  justify-content: center;
}
.roadmap-range-nav button:hover { background: #f2f2f7; }

.view-toggle {
  display: flex;
  background: #fff;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  overflow: hidden;
}
.view-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-mid);
  cursor: pointer;
  transition: background 0.12s;
}
.view-btn.active {
  background: var(--accent);
  color: #fff;
}
.view-btn:hover:not(.active) { background: #f2f2f7; }

.btn-add {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.12s;
}
.btn-add:hover { opacity: 0.85; }

/* Gantt container */
.gantt-wrap {
  flex: 1;
  overflow: auto;
  position: relative;
}

.gantt-table {
  display: flex;
  flex-direction: column;
  min-width: max-content;
}

/* Header row */
.gantt-head {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 5;
  background: #ebebf0;
  border-bottom: 1px solid #e5e5ea;
}

.gantt-task-col-head {
  width: var(--task-col-w);
  min-width: var(--task-col-w);
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-light);
  border-right: 1px solid #e5e5ea;
  position: sticky;
  left: 0;
  background: #ebebf0;
  z-index: 6;
}

.gantt-dates-head {
  display: flex;
}

.gantt-date-cell {
  width: var(--day-w);
  min-width: var(--day-w);
  padding: 4px 6px;
  border-right: 1px solid #e5e5ea;
  text-align: center;
}
.gantt-date-cell.today { background: #fff; }
.gantt-date-cell.weekend { background: #f7f7f9; }

.gantt-date-day {
  display: block;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-light);
  letter-spacing: 0.4px;
}
.gantt-date-num {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dark);
}
.gantt-date-cell.today .gantt-date-num { color: var(--accent); }
.gantt-today-label {
  display: block;
  font-size: 8px;
  color: var(--accent);
  font-weight: 600;
}

/* Task rows */
.gantt-row {
  display: flex;
  border-bottom: 1px solid #e5e5ea;
  height: var(--row-h);
}
.gantt-row:hover { background: rgba(0,0,0,0.015); }

.gantt-task-cell {
  width: var(--task-col-w);
  min-width: var(--task-col-w);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-right: 1px solid #e5e5ea;
  background: #fff;
  position: sticky;
  left: 0;
  z-index: 2;
  overflow: hidden;
}

.task-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c7c7cc;
  flex-shrink: 0;
}
.task-dot.done { background: var(--done-color); }

.task-name {
  font-size: 11px;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Timeline */
.gantt-timeline {
  display: flex;
  position: relative;
}

.gantt-day {
  width: var(--day-w);
  min-width: var(--day-w);
  border-right: 1px solid #ebebf0;
  height: 100%;
}
.gantt-day.today { background: rgba(224,123,47,0.04); }
.gantt-day.weekend { background: #f7f7f9; }

.gantt-bar {
  position: absolute;
  top: 6px;
  bottom: 6px;
  border-radius: 10px;
  background: var(--bar-color);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-mid);
  min-width: 20px;
}
.gantt-bar.done { background: var(--bar-done); color: #2a7a3b; }

.bar-check {
  font-size: 11px;
  color: var(--done-color);
  flex-shrink: 0;
}
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bar-badge {
  background: #c7c7cc;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 4px;
  flex-shrink: 0;
  margin-left: auto;
}

/* No deadline */
.gantt-nodl {
  border-top: 2px solid #e5e5ea;
  background: #fff;
  padding: 10px 16px;
}
.gantt-nodl-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-light);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nodl-hint {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #c7c7cc;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  color: var(--text-light);
}
.gantt-nodl-items { display: flex; gap: 10px; flex-wrap: wrap; }
.gantt-nodl-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #e5e5ea;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-dark);
  cursor: pointer;
}
.gantt-nodl-item:hover { border-color: #c7c7cc; }

.btn-add-float {
  position: absolute;
  bottom: 70px;
  right: 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(224,123,47,0.4);
}

/* ────────────────────────────────────────────
   AI АГЕНТЫ
───────────────────────────────────────────── */
.ai-page {
  height: 100%;
  display: flex;
  overflow: hidden;
  background: var(--content-bg);
}

/* Left sidebar */
.ai-sidebar {
  width: 200px;
  min-width: 200px;
  background: #fff;
  border-right: 1px solid #e5e5ea;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.ai-sidebar .search-box {
  margin: 10px;
  width: auto;
}

.ai-tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-dark);
  cursor: pointer;
  font-weight: 600;
  background: #f2f2f7;
  border-left: 3px solid var(--accent);
}

.ai-category {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-mid);
  border-bottom: 1px solid #f2f2f7;
  user-select: none;
}
.ai-category:hover { background: #f9f9fb; }

.ai-cat-left { display: flex; align-items: center; gap: 6px; }
.ai-cat-arrow { font-size: 9px; color: var(--text-light); }
.ai-cat-count {
  background: #e5e5ea;
  color: var(--text-mid);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
}

/* Main chart area */
.ai-main {
  flex: 1;
  overflow: auto;
  padding: 24px;
}

.ai-main-header { margin-bottom: 28px; }
.ai-main-header h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-dark);
  margin-bottom: 4px;
}
.ai-main-header p { font-size: 12px; color: var(--text-mid); }

/* Org chart */
.org-chart { min-width: 900px; position: relative; }
.orch-wires { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 0; overflow: visible; display: none; }

.org-row {
  display: flex;
  gap: 10px;
  margin-bottom: 32px;
  align-items: flex-start;
}
.org-row.row-orchestrators { justify-content: space-between; padding: 0 5%; }
.org-row.row-l1-left { flex-wrap: wrap; }
.org-row.row-l1-right { justify-content: flex-end; gap: 10px; }
.org-row.row-l2 { flex-wrap: wrap; justify-content: flex-end; }

.agent-card {
  border: 1px solid #d1d1d6;
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  min-width: 100px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, background 0.15s;
  position: relative;
  z-index: 1;
}
.agent-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.1); }

/* ── Живая оркестрация: подсветка узлов оргчарта ── */
.agent-card.orch-hub { border-color: #3a7afe; box-shadow: 0 0 0 2px rgba(58,122,254,0.25); }
.agent-card.orch-pulse { animation: orchHub 1.1s ease-in-out infinite; }
@keyframes orchHub { 0%,100% { box-shadow: 0 0 0 2px rgba(58,122,254,0.30); } 50% { box-shadow: 0 0 0 7px rgba(58,122,254,0.08); } }
.agent-card.orch-working { border-color: #e07b2f; background: #fff8f4; animation: orchWork 0.9s ease-in-out infinite; }
@keyframes orchWork { 0%,100% { box-shadow: 0 0 0 1px rgba(224,123,47,0.35); } 50% { box-shadow: 0 0 0 6px rgba(224,123,47,0.12); } }
.agent-card.orch-done { border-color: #34c759; background: #f2fff6; }

/* SVG-линии оркестрации */
.wire-working { stroke-dasharray: 7 6; animation: wireFlow 0.55s linear infinite; }
@keyframes wireFlow { to { stroke-dashoffset: -13; } }
.wire-done { opacity: 0.5; }

.agent-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.agent-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8e8e93;
  flex-shrink: 0;
}
.agent-name-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
}
.agent-idle {
  font-size: 10px;
  color: var(--text-light);
  padding-left: 13px;
}

/* Connector lines between org rows */
.org-connector {
  height: 24px;
  position: relative;
  margin-bottom: 8px;
}
.org-connector::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: 100%;
  background: #d1d1d6;
}

/* ────────────────────────────────────────────
   MODAL (add task)
───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e5ea;
}

.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--text-dark); }

.modal-close {
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { background: #f2f2f7; color: var(--text-dark); }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.modal-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  letter-spacing: 0.4px;
  margin-bottom: 5px;
}

.modal-input {
  width: 100%;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-dark);
  outline: none;
  font-family: var(--font);
  transition: border-color 0.15s;
}
.modal-input:focus { border-color: var(--accent); }

.modal-row { display: flex; gap: 12px; }
.modal-row > div { flex: 1; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid #e5e5ea;
  background: #f9f9fb;
}

.modal-btn-cancel {
  border: 1px solid #e5e5ea;
  background: #fff;
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mid);
  cursor: pointer;
}
.modal-btn-cancel:hover { background: #f2f2f7; }

.modal-btn-save {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s;
}
.modal-btn-save:hover { opacity: 0.85; }

/* ────────────────────────────────────────────
   ТИКЕТЫ
───────────────────────────────────────────── */
.tk-page {
  height: 100%;
  display: flex;
  overflow: hidden;
  background: var(--content-bg);
}

/* Left sidebar */
.tk-sidebar {
  width: 210px;
  min-width: 210px;
  background: #fff;
  border-right: 1px solid #e5e5ea;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
}

.tk-sidebar-section { padding: 8px 0; }

.tk-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-mid);
  cursor: pointer;
  user-select: none;
}
.tk-section-header:hover { background: #f9f9fb; }

.tk-dept-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 20px;
  font-size: 12px;
  color: var(--text-mid);
  cursor: pointer;
  transition: background 0.1s;
}
.tk-dept-item:hover { background: #f2f2f7; }
.tk-dept-item.active { background: #f0f0f5; color: var(--text-dark); font-weight: 600; }

.tk-dept-hash { color: var(--text-light); font-size: 12px; }
.tk-dept-name { flex: 1; }
.tk-dept-count {
  font-size: 10px;
  font-weight: 700;
  background: #e5e5ea;
  color: var(--text-mid);
  border-radius: 8px;
  padding: 1px 5px;
}

.tk-sidebar-divider { height: 1px; background: #e5e5ea; margin: 4px 0; }

.tk-special-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text-mid);
  cursor: pointer;
  transition: background 0.1s;
}
.tk-special-item:hover { background: #f2f2f7; }
.tk-special-item.active {
  background: #f0f0f5;
  color: var(--text-dark);
  font-weight: 600;
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}
.tk-hash { color: var(--text-light); }

/* Main content */
.tk-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

.tk-main-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 24px 12px;
  border-bottom: 1px solid #e5e5ea;
  flex-shrink: 0;
}

.tk-breadcrumb-section {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.tk-page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
}

.tk-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.tk-changed { font-size: 11px; color: var(--text-light); }

.tk-btn-history {
  border: 1px solid #e5e5ea;
  background: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-mid);
  cursor: pointer;
}
.tk-btn-history:hover { background: #f2f2f7; }

.tk-btn-save {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.3s;
}
.tk-btn-save:hover { opacity: 0.85; }

/* Editor */
.tk-editor-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 24px 0;
}

.tk-editor-inner { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.tk-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}

.tk-editor {
  flex: 1;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dark);
  font-family: var(--font);
  resize: none;
  outline: none;
  background: #fafafa;
  transition: border-color 0.15s;
}
.tk-editor:focus { border-color: var(--accent); background: #fff; }

.tk-editor-footer {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 11px;
  color: var(--text-light);
  flex-shrink: 0;
}

.tk-char-count { font-weight: 600; }

/* Template section */
.tk-template-section {
  border-top: 1px solid #e5e5ea;
  flex-shrink: 0;
  max-height: 280px;
  overflow-y: auto;
}

.tk-template-header {
  padding: 12px 24px;
  cursor: pointer;
  background: #fffbf7;
  border-bottom: 1px solid #fde8d0;
}
.tk-template-header:hover { background: #fff6ee; }

.tk-template-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.tk-template-title-row strong { font-size: 13px; color: var(--text-dark); }

.tk-template-desc { font-size: 11px; color: var(--text-light); line-height: 1.4; }

.tk-template-body { padding: 16px 24px; display: flex; flex-direction: column; gap: 14px; }

.tk-field-group { display: flex; flex-direction: column; gap: 6px; }

.tk-field-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-light);
}

.tk-field-value { font-size: 12px; color: var(--text-mid); }

.tk-field-input {
  border: 1px solid #e5e5ea;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--text-dark);
  resize: none;
  outline: none;
}
.tk-field-input:focus { border-color: var(--accent); }

.tk-warning-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fffbf0;
  border: 1px solid #fde8a0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #7a5c00;
}

.tk-threshold-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.tk-threshold-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text-light);
  padding: 6px 8px;
  border-bottom: 1px solid #e5e5ea;
}
.tk-threshold-table td {
  padding: 7px 8px;
  color: var(--text-mid);
  border-bottom: 1px solid #f2f2f7;
}

.tk-action {
  display: inline-block;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  font-family: monospace;
}
.tk-action.hitl      { background: #e8f4fd; color: #0a6ebd; }
.tk-action.escalated { background: #fdecea; color: #c0392b; }

/* ────────────────────────────────────────────
   TABLE (shared: справочники + тикеты)
───────────────────────────────────────────── */
.table-wrap {
  flex: 1;
  overflow: auto;
  margin: 0 16px 16px;
  border: 1px solid #e5e5ea;
  border-radius: 10px;
  background: #fff;
}

.sprav-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.sprav-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-light);
  padding: 10px 12px;
  border-bottom: 1px solid #e5e5ea;
  background: #f9f9fb;
  position: sticky;
  top: 0;
  z-index: 1;
}
.sprav-table td {
  padding: 9px 12px;
  color: var(--text-mid);
  border-bottom: 1px solid #f2f2f7;
  vertical-align: middle;
}
.sprav-table tbody tr:last-child td { border-bottom: none; }
.sprav-table tbody tr:hover { background: #fafafa; }

.td-num  { color: var(--text-light) !important; font-size: 12px !important; }
.td-name { color: var(--text-dark)  !important; font-weight: 500; }
.td-date { font-size: 12px; color: var(--text-light) !important; }
.td-desc { color: var(--text-light) !important; font-size: 12px; }

.td-actions { display: flex; gap: 4px; justify-content: flex-end; }

.tbl-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #e5e5ea;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  transition: background 0.12s, color 0.12s;
}
.tbl-btn:hover { background: #f2f2f7; color: var(--text-dark); }
.tbl-btn.del-btn:hover { background: #fdecea; color: #c0392b; border-color: #f5c6c3; }

/* Badges */
.badge {
  display: inline-block;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-active  { background: #e8f8ef; color: #2a7a3b; }
.badge-off     { background: #f2f2f7; color: #8e8e93; }
.st-open       { background: #fdecea; color: #c0392b; }
.st-progress   { background: #fff3e0; color: #e07b2f; }
.st-closed     { background: #e8f8ef; color: #2a7a3b; }

.empty-table {
  padding: 40px;
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
}

/* List view toolbar additions */
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #e5e5ea;
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mid);
  cursor: pointer;
  flex-shrink: 0;
}
.back-btn:hover { background: #f2f2f7; }

.list-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 8px;
}
.sprav-label-sm {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-light);
}
.list-title > *:last-child { font-size: 14px; font-weight: 700; color: var(--text-dark); }

.input-error { border-color: #c0392b !important; }

/* ── Agent detail panel ── */
.agent-card.selected {
  border-color: var(--accent);
  background: #fff8f4;
}

.agent-detail-panel {
  width: 46%;
  min-width: 460px;
  max-width: 760px;
  background: #fff;
  border-left: 1px solid #e5e5ea;
  display: flex;
  flex-direction: column;
  padding: 22px 26px;
  gap: 14px;
  overflow-y: auto;
}

.agent-detail-panel.kyc-wide {
  width: 52%;
  min-width: 560px;
  max-width: 860px;
}

.adp-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.adp-close {
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
}
.adp-close:hover { background: #f2f2f7; color: var(--text-dark); }

.adp-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: #f9f9fb;
  border-radius: 8px;
}

.adp-desc {
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.6;
}

.adp-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: -6px;
}

.adp-activity {
  font-size: 12px;
  color: var(--text-light);
  padding: 10px;
  background: #f9f9fb;
  border-radius: 8px;
  text-align: center;
}

/* ── Agent chat ── */
.adp-chat {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
  min-height: 80px;
}

.chat-empty {
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
  padding: 20px 0;
}

.chat-msg { display: flex; flex-direction: column; gap: 2px; }

.chat-msg.user { align-items: flex-end; }
.chat-msg.assistant { align-items: flex-start; }

.chat-agent-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text-light);
  margin-left: 2px;
}

.chat-bubble {
  max-width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.assistant { width: 100%; }
.chat-msg.assistant .chat-bubble { width: 100%; }

.chat-msg.user .chat-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.chat-msg.assistant .chat-bubble {
  background: #f2f2f7;
  color: var(--text-dark);
  border-bottom-left-radius: 3px;
}

.adp-chat-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex-shrink: 0;
}

.adp-chat-input {
  flex: 1;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-dark);
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.5;
}
.adp-chat-input:focus { border-color: var(--accent); }

/* ── Индикатор «агент работает» ── */
.ai-loading {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 13px 15px;
  background: #fff8f4;
  border: 1px solid #fde8d5;
  border-radius: 10px;
  flex-shrink: 0;
}
.ai-loading-text {
  font-size: 13px;
  font-weight: 600;
  color: #e07b2f;
  display: flex;
  align-items: center;
  gap: 9px;
}
.ai-loading-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  animation: aiPulse 1s ease-in-out infinite;
}
.ai-loading-sec { margin-left: auto; font-variant-numeric: tabular-nums; color: #b06428; }
.ai-loading-sec b { color: #e07b2f; }
.ai-loading-track {
  height: 6px; border-radius: 3px;
  background: #f3e2d6; overflow: hidden;
}
.ai-loading-fill {
  height: 100%; width: 0%;
  background: var(--accent); border-radius: 3px;
  transition: width .5s linear;
}
@keyframes aiPulse { 0%,100% { opacity: .25; transform: scale(.85); } 50% { opacity: 1; transform: scale(1); } }

/* ── Кнопка «Скачать в документ» ── */
.ai-dl-btn {
  align-self: flex-start;
  margin-top: 5px;
  border: 1px solid #d1d1d6;
  background: #fff;
  color: #3a3a3c;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.ai-dl-btn:hover { border-color: var(--accent); color: var(--accent); }
.ai-dl-btn.wide { align-self: stretch; text-align: center; margin-top: 10px; padding: 9px; font-size: 12px; }

/* ── KYC History ── */
.kyc-history-list {
  max-height: 128px;
  overflow-y: auto;
  border: 1px solid #e0e0e8;
  border-radius: 8px;
  background: #fafafa;
  margin-bottom: 8px;
}
.kyc-history-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background .1s;
}
.kyc-history-item:last-child { border-bottom: none; }
.kyc-history-item:hover { background: #f0f0f8; }
.kyc-hist-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.kyc-hist-dot.low    { background: #34c759; }
.kyc-hist-dot.medium { background: #ff9500; }
.kyc-hist-dot.high   { background: #ff3b30; }
.kyc-hist-info { min-width: 0; flex: 1; }
.kyc-hist-name { font-size: 12px; font-weight: 600; color: #1c1c1e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kyc-hist-meta { font-size: 10px; color: #8e8e93; }

/* ── KYC Export button ── */
.kyc-export-btn {
  padding: 4px 12px;
  background: #f2f2f7;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 12px;
  color: #555;
  cursor: pointer;
  transition: background .12s;
}
.kyc-export-btn:hover { background: #e0e0e8; }

/* ── Legal contract input ── */
.legal-contract-input {
  width: 100%;
  min-height: 110px;
  max-height: 220px;
  resize: vertical;
  background: #f9f9fb;
  border: 1px solid #e0e0e8;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: #1c1c1e;
  font-family: inherit;
  line-height: 1.55;
  box-sizing: border-box;
  margin-bottom: 8px;
  transition: border-color .15s;
}
.legal-contract-input:focus { outline: none; border-color: var(--accent); }
.legal-contract-input.drag-over { border-color: var(--accent); border-style: dashed; background: #fff8f4; }

/* Загрузка файла договора */
.legal-file-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.legal-file-btn {
  border: 1px dashed #c1c1c9;
  background: #fafafc;
  color: #3a3a3c;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.legal-file-btn:hover { border-color: var(--accent); color: var(--accent); background: #fff8f4; }
.legal-file-btn:disabled { opacity: .5; cursor: default; }
.legal-file-status { font-size: 11px; color: #8e8e93; flex: 1; min-width: 120px; }

.legal-analyze-btn {
  width: 100%;
  padding: 9px;
  background: #1c1c1e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background .15s;
}
.legal-analyze-btn:hover { background: #333; }
.legal-analyze-btn:disabled { opacity: .5; cursor: default; }

/* ── Analyst web badge ── */
.analyst-web-badge {
  font-size: 10px;
  font-weight: 600;
  color: #34c759;
  background: #f0fff4;
  border: 1px solid #c3e6cb;
  border-radius: 10px;
  padding: 1px 8px;
  letter-spacing: .2px;
}

/* ── Quick chips ── */
.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 4px 12px 8px;
}
.ai-chip {
  background: #f2f2f7;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 3px 11px;
  font-size: 11px;
  color: #555;
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.ai-chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Markdown styles in chat bubbles ── */
.chat-bubble .md-h1, .orch-step-response .md-h1 { display:block; font-size:17px; font-weight:700; color:#1c1c1e; margin:10px 0 4px; }
.chat-bubble .md-h2, .orch-step-response .md-h2 { display:block; font-size:15px; font-weight:700; color:#1c1c1e; margin:9px 0 4px; }
.chat-bubble .md-h3, .orch-step-response .md-h3 { display:block; font-size:14px; font-weight:700; color:#3a3a3c; margin:8px 0 3px; }
.chat-bubble .md-ul, .orch-step-response .md-ul,
.chat-bubble .md-ol, .orch-step-response .md-ol { margin:5px 0 6px 18px; padding:0; }
.chat-bubble .md-ul li, .chat-bubble .md-ol li,
.orch-step-response .md-ul li, .orch-step-response .md-ol li { margin:3px 0; font-size:14px; line-height:1.6; }
.chat-bubble .md-pre, .orch-step-response .md-pre { background:#1e1e2e; border:1px solid #ccc; border-radius:6px; padding:9px 12px; margin:6px 0; overflow-x:auto; }
.chat-bubble .md-pre code, .orch-step-response .md-pre code { font-family:Consolas,monospace; font-size:12px; color:#e8e8ed; white-space:pre; }
.chat-bubble .md-code, .orch-step-response .md-code { background:#f0f0f5; border-radius:3px; padding:1px 5px; font-family:Consolas,monospace; font-size:12px; color:#c0392b; }
.chat-bubble .md-gap, .orch-step-response .md-gap { height:5px; display:block; }

.adp-send-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.12s;
}
.adp-send-btn:hover:not(:disabled) { opacity: 0.85; }
.adp-send-btn:disabled { opacity: 0.5; cursor: default; }

.adp-clear-btn {
  margin-left: auto;
  border: none;
  background: transparent;
  font-size: 10px;
  color: var(--text-light);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.adp-clear-btn:hover { background: #f2f2f7; color: var(--text-mid); }

/* ── CEO Orchestration ── */
.adp-ceo-hint {
  font-size: 11px;
  color: var(--text-light);
  background: #f9f9fb;
  padding: 6px 10px;
  border-radius: 6px;
  line-height: 1.5;
}

.orch-steps-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

.orch-step {
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  overflow: hidden;
}

.orch-step.working { border-color: #fde8d5; }
.orch-step.done    { border-color: #d1f0db; }

.orch-step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #f9f9fb;
}

.orch-step.working .orch-step-header { background: #fff8f4; }
.orch-step.done    .orch-step-header { background: #f0fff4; }

.orch-step-agent {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dark);
}

.orch-step-status { font-size: 11px; }

.orch-step-task {
  font-size: 10px;
  color: var(--text-light);
  padding: 4px 10px;
  border-bottom: 1px solid #f2f2f7;
  white-space: pre-wrap;
}

.orch-step-response {
  font-size: 11px;
  color: var(--text-mid);
  padding: 8px 10px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 180px;
  overflow-y: auto;
}

.agent-status-dot.active { background: #34c759; }

.adp-run-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s, background 0.3s;
  flex-shrink: 0;
}
.adp-run-btn:hover:not(:disabled) { opacity: 0.85; }
.adp-run-btn:disabled { opacity: 0.55; cursor: default; }

.adp-task-input {
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--text-dark);
  resize: vertical;
  min-height: 72px;
  outline: none;
  transition: border-color 0.15s;
}
.adp-task-input:focus { border-color: var(--accent); }

.adp-response {
  font-size: 12px;
  color: var(--text-mid);
  line-height: 1.65;
  background: #f9f9fb;
  border-radius: 8px;
  padding: 10px;
  min-height: 60px;
  white-space: pre-wrap;
  flex: 1;
  overflow-y: auto;
}
.adp-response-loading { color: var(--text-light); font-style: italic; }

.adp-key-warn {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fff8f4;
  border: 1px solid #fde8d5;
  border-radius: 8px;
  padding: 10px;
}
.adp-key-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--accent);
}
.adp-key-input {
  border: 1px solid #e5e5ea;
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 12px;
  font-family: monospace;
  outline: none;
}
.adp-key-input:focus { border-color: var(--accent); }
.adp-key-save {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-end;
}
.adp-key-save:hover { opacity: 0.85; }

/* ── KYC Check Panel ── */
.kyc-check-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px 12px;
  background: #f9f9fb;
  border-radius: 8px;
  margin-bottom: 8px;
}
.kyc-code-input {
  flex: 1;
  min-width: 120px;
  border: 1px solid #e5e5ea;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: monospace;
  outline: none;
  background: #fff;
}
.kyc-code-input:focus { border-color: var(--accent); }
.kyc-check-btn {
  border: none;
  background: #34c759;
  color: #fff;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.kyc-check-btn:hover { opacity: 0.85; }
.kyc-check-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.kyc-status {
  width: 100%;
  font-size: 11px;
  min-height: 14px;
}

/* ── Отдельный процесс в оргчарте (агент вне команд CEO/CTO) ── */
.org-standalone {
  border: 1px dashed #c7c7cc;
  border-radius: 12px;
  padding: 10px 14px 12px;
  background: rgba(224, 123, 47, 0.04);
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.org-standalone-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  color: #e07b2f;
}
.org-standalone-cards {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Опт-аудит воронки 149 (агент opt-audit) ── */
.opt-check-panel {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 10px 12px; background: #f9f9fb; border-radius: 8px; margin-bottom: 8px;
}
.opt-check-btn {
  flex: 1; min-width: 160px; border: none; background: #e07b2f; color: #fff;
  border-radius: 6px; padding: 8px 14px; font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.opt-check-btn:hover { opacity: .9; }
.opt-check-btn:disabled { opacity: .5; cursor: not-allowed; }
.opt-refresh-btn {
  border: 1px solid #e5e5ea; background: #fff; color: #666; border-radius: 6px;
  padding: 8px 11px; font-size: 14px; cursor: pointer;
}
.opt-refresh-btn:hover { background: #f2f2f7; }
.opt-refresh-btn:disabled { opacity: .5; cursor: not-allowed; }
.opt-status { width: 100%; font-size: 11px; min-height: 14px; }
.opt-hint {
  font-size: 12px; color: #8e8e93; line-height: 1.5; padding: 8px 2px;
}
.opt-summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 10px; }
.opt-pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.opt-pill.opt-red    { background: #ffe5e2; color: #c0392b; }
.opt-pill.opt-yellow { background: #fff4d6; color: #a67c00; }
.opt-pill.opt-green  { background: #e3f7e8; color: #1e8e3e; }
.opt-pill.opt-pending { background: #eef0f4; color: #5f5e5a; }
.opt-pending-note { font-size: 11px; color: #8e8e93; line-height: 1.5; margin: -2px 0 10px; }
.opt-stale-note { font-size: 12px; color: #b26a00; background: #fff6e5; border: 1px solid #ffd591;
  border-radius: 8px; padding: 7px 10px; line-height: 1.45; margin: -2px 0 10px; }

/* ── Качество звонков (агент opt-qa) ── */
.qa-score-badge { display: inline-block; min-width: 26px; text-align: center; font-weight: 700;
  font-size: 11px; border-radius: 6px; padding: 1px 5px; }
.qa-score-badge.big { font-size: 14px; min-width: 34px; padding: 2px 6px; }
.qa-good { background: #e6f7ec; color: #1e8e3e; }
.qa-mid  { background: #fff6e5; color: #b26a00; }
.qa-low  { background: #fdeaea; color: #c62828; }
.qa-mgr-meta { font-size: 10px; color: #8e8e93; margin-left: 4px; }
.qa-crit-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.qa-crit { font-size: 10px; border-radius: 5px; padding: 1px 6px; }
.qa-line { font-size: 12px; line-height: 1.45; margin-top: 4px; }
.qa-line-good { color: #1e8e3e; }
.qa-line-gap  { color: #b26a00; }
.qa-line-tip  { color: #1c1c1e; }
.opt-summary-meta { font-size: 11px; color: #8e8e93; }
.opt-empty { font-size: 13px; color: #1e8e3e; padding: 10px 2px; }
.opt-findings-list { display: flex; flex-direction: column; gap: 8px; }
.opt-finding {
  border: 1px solid #e5e5ea; border-left-width: 3px; border-radius: 8px;
  padding: 10px 12px; background: #fff;
}
.opt-finding.opt-red    { border-left-color: #ff3b30; }
.opt-finding.opt-yellow { border-left-color: #ffcc00; }
.opt-finding-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.opt-finding-dot { font-size: 11px; }
.opt-finding-title { font-size: 13px; font-weight: 700; color: #1c1c1e; }
.opt-deal-link { font-size: 11px; color: #007aff; text-decoration: none; margin-left: auto; }
.opt-deal-link:hover { text-decoration: underline; }
.opt-finding-meta { font-size: 11px; color: #6b6b70; margin-top: 4px; }
.opt-finding-reason { font-size: 12.5px; color: #1c1c1e; line-height: 1.5; margin-top: 5px; }
.opt-finding-quote {
  font-size: 12px; color: #444; font-style: italic; line-height: 1.5;
  margin-top: 6px; padding: 6px 10px; background: #f5f5f7; border-radius: 6px;
}
.opt-finding-note { font-size: 11px; color: #a67c00; margin-top: 5px; }
.opt-quote-src { font-size: 10.5px; color: #8e8e93; font-style: normal; margin-top: 4px; }
/* Сводка по сотрудникам */
.opt-mgr-head { font-size: 10px; font-weight: 700; letter-spacing: .5px; color: #8e8e93; margin: 4px 0 6px; }
.opt-mgr-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.opt-mgr-chip {
  border: 1px solid #e5e5ea; background: #fff; border-radius: 20px; padding: 4px 10px;
  font-size: 12px; color: #1c1c1e; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
}
.opt-mgr-chip:hover { background: #f7f7fa; }
.opt-mgr-chip.active { border-color: #e07b2f; background: #fdf1e8; color: #e07b2f; font-weight: 500; }
.opt-mgr-b { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; color: #fff; }
.opt-mgr-b.red { background: #ff3b30; }
.opt-mgr-b.yellow { background: #e0a11f; }
.opt-mgr-tr { font-size: 10px; font-weight: 700; margin-left: 2px; }
.opt-mgr-tr.up { color: #ff3b30; }
.opt-mgr-tr.down { color: #1e8e3e; }
.opt-mgr-tr.flat { color: #b4b2a9; }
.opt-filter-note { font-size: 12px; color: #6b6b70; margin-bottom: 8px; }
.opt-filter-clear { color: #007aff; cursor: pointer; }
.opt-filter-clear:hover { text-decoration: underline; }
.opt-finding-last {
  font-size: 12px; color: #1c1c1e; line-height: 1.5;
  margin-top: 6px; padding: 6px 10px; background: #eef4fb; border-radius: 6px;
}
.opt-disclaimer { font-size: 10.5px; color: #a0a0a5; line-height: 1.5; margin-top: 10px; }
/* Наставник ОПТ */
.mentor-advice {
  font-size: 12.5px; line-height: 1.6; color: #1c1c1e; margin-top: 8px;
  padding: 10px 12px; background: #faf9ff; border: 1px solid #e8e5f8; border-radius: 8px;
}
.mentor-advice .md-h2 { font-size: 13px; margin: 10px 0 4px; }
.mentor-advice .md-h2:first-child { margin-top: 0; }
.mentor-intro {
  font-size: 12px; line-height: 1.55; color: #3c3c43;
  background: #faf9ff; border: 1px solid #e8e5f8; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px;
}
.mentor-intro b { color: #1c1c1e; font-weight: 600; }
.mentor-mgr-sel {
  flex: 1; min-width: 140px; border: 1px solid #e5e5ea; border-radius: 6px;
  padding: 7px 10px; font-size: 13px; background: #fff; outline: none;
}
.mentor-deal-list { display: flex; flex-direction: column; gap: 5px; margin: 4px 0 6px; }
.mentor-deal-row {
  border: 1px solid #e8e5f8; border-radius: 8px; padding: 8px 10px; cursor: pointer; background: #fff;
}
.mentor-deal-row:hover { background: #faf9ff; border-color: #c9bff5; }
.mentor-deal-main { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mentor-deal-title { font-size: 13px; font-weight: 500; color: #1c1c1e; }
.mentor-deal-stage { font-size: 11px; color: #7a5af8; white-space: nowrap; }
.mentor-deal-sub { font-size: 11px; color: #8e8e93; margin-top: 3px; }
.mentor-deal-action { font-size: 12.5px; color: #1c1c1e; line-height: 1.45; margin-top: 4px; }
.mentor-deal-cta { font-size: 11px; color: #7a5af8; margin-top: 6px; opacity: .75; }
.mentor-deal-row:hover .mentor-deal-cta { opacity: 1; }
.mentor-prio { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 10px; margin-right: 4px; vertical-align: 1px; }
.mentor-prio.high { background: #ffe5e2; color: #c0392b; }
.mentor-prio.med { background: #fff4d6; color: #a67c00; }
.mentor-prio.low { background: #e3f7e8; color: #1e8e3e; }

/* ── Update Overlay (blocking) ── */
#updateOverlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: linear-gradient(160deg, #080d1a 0%, #0c1530 60%, #091220 100%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 0 80px;
  overflow: hidden;
  color: #f2f2f7;
}
.upd-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  margin-bottom: 20px;
}
.upd-version-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 2px;
  min-height: 32px;
}
.upd-version-old {
  font-size: 22px;
  font-weight: 600;
  color: rgba(255,255,255,0.28);
  text-decoration: line-through;
  text-decoration-color: rgba(255,255,255,0.35);
}
.upd-version-arrow {
  font-size: 22px;
  color: rgba(255,255,255,0.3);
}
.upd-version-new {
  font-size: 72px;
  font-weight: 800;
  background: linear-gradient(90deg, #4f8ef7 0%, #43daa2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.05;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  min-height: 80px;
}
.upd-ready-label {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 14px;
}
.upd-description {
  font-size: 14px;
  color: rgba(255,255,255,0.48);
  max-width: 460px;
  line-height: 1.7;
  margin-bottom: 28px;
  min-height: 0;
}
.upd-progress-wrap {
  width: 400px;
  margin-bottom: 28px;
}
.upd-progress-bar-bg {
  width: 100%;
  height: 5px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.upd-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4f8ef7, #43daa2);
  border-radius: 3px;
  transition: width .3s ease;
}
.upd-progress-pct {
  font-size: 12px;
  color: rgba(255,255,255,0.35);
  text-align: right;
}
.upd-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 36px;
  max-width: 560px;
}
.upd-tag-item {
  background: rgba(79, 142, 247, 0.12);
  border: 1px solid rgba(79, 142, 247, 0.28);
  color: rgba(255,255,255,0.72);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
}
.upd-install-btn {
  background: linear-gradient(90deg, #3f6ef5 0%, #5b3fa8 100%);
  color: #fff;
  border: none;
  border-radius: 28px;
  padding: 14px 36px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: opacity .2s;
  box-shadow: 0 4px 28px rgba(63, 110, 245, 0.4);
}
.upd-install-btn:hover { opacity: .85; }
.upd-wave-bg {
  position: absolute;
  bottom: -100px;
  left: -5%;
  right: -5%;
  height: 360px;
  background: radial-gradient(ellipse 70% 60% at 50% 100%, rgba(67,218,162,0.1) 0%, rgba(79,142,247,0.07) 40%, transparent 70%);
  pointer-events: none;
}

/* ── Version popup ── */
#verPopup {
  position: fixed;
  left: 60px;
  top: 8px;
  background: #1c1c1e;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 16px 20px;
  z-index: 9998;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  min-width: 170px;
  pointer-events: auto;
}
.ver-popup-label {
  font-size: 11px;
  color: rgba(255,255,255,0.38);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.ver-popup-ver {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(90deg, #4f8ef7 0%, #43daa2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.15;
}
.ver-popup-copy {
  font-size: 10px;
  color: rgba(255,255,255,0.18);
  margin-top: 10px;
}

/* ── KYC Modal ── */
.kyc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.kyc-modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 920px;
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
.kyc-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e5e5ea;
  flex-shrink: 0;
}
.kyc-modal-subtitle {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  color: #8e8e93;
  margin-bottom: 3px;
  text-transform: uppercase;
}
.kyc-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #1c1c1e;
}
.kyc-modal-close {
  width: 32px; height: 32px;
  border: none;
  background: #f2f2f7;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  color: #636366;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.kyc-modal-close:hover { background: #e5e5ea; color: #1c1c1e; }
.kyc-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 24px;
}

/* ── KYC Main Area Report ── */
.kyc-main-report {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.kyc-main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px 14px;
  border-bottom: 1px solid #e5e5ea;
  flex-shrink: 0;
}
.kyc-back-btn {
  padding: 7px 16px;
  background: #f2f2f7;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  color: #636366;
  cursor: pointer;
  transition: background .15s;
}
.kyc-back-btn:hover { background: #e5e5ea; color: #1c1c1e; }
.kyc-main-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.kyc-main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.kyc-main-col {
  background: #f9f9fb;
  border-radius: 10px;
  padding: 14px 16px;
}

/* ── KYC Report Card ── */
.kyc-report-card {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  background: #f9f9fb;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}
.kyc-card-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  color: #8e8e93;
  margin: 6px 0 4px;
  text-transform: uppercase;
}
.kyc-card-row {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid #f0f0f5;
  align-items: flex-start;
}
.kyc-card-label {
  min-width: 140px;
  max-width: 140px;
  color: #8e8e93;
  font-size: 11px;
  flex-shrink: 0;
}
.kyc-card-val {
  color: #1c1c1e;
  font-size: 12px;
  line-height: 1.4;
  word-break: break-word;
  flex: 1;
}
.kyc-index-badge {
  display: inline-block;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
}
.kyc-web-result {
  padding: 4px 0;
  border-bottom: 1px solid #f0f0f5;
}
.kyc-web-title {
  font-weight: 600;
  color: #1c1c1e;
  font-size: 11px;
}
.kyc-web-snippet {
  color: #8e8e93;
  font-size: 10px;
  margin-top: 2px;
}
.kyc-verdict-block {
  padding: 10px 12px;
  background: #fff;
  border-radius: 8px;
  border-left: 3px solid #e5e5ea;
  margin-bottom: 6px;
  font-size: 12px;
}
.kyc-verdict-header {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
}
.kyc-verdict-body {
  color: #3a3a3c;
  white-space: pre-wrap;
  line-height: 1.5;
}
.kyc-verdict-pending {
  text-align: center;
  color: #8e8e93;
  font-size: 12px;
  padding: 10px;
}

/* ── Org Structure Page ── */
.org-page {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--content-bg);
}

.org-page-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid #e5e5ea;
  flex-shrink: 0;
}
.org-page-header h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text-dark);
  margin-bottom: 3px;
}
.org-page-header p { font-size: 12px; color: var(--text-mid); }

.org-canvas {
  flex: 1;
  overflow: auto;
  padding: 28px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Root node */
.org-root-node {
  background: var(--card-bg);
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 14px 24px;
  text-align: center;
  box-shadow: 0 2px 14px rgba(224,123,47,0.14);
  min-width: 230px;
}
.orn-company {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--accent);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.orn-head { font-size: 13px; font-weight: 600; color: var(--text-dark); margin-bottom: 2px; }
.orn-role { font-size: 11px; color: var(--text-mid); margin-bottom: 8px; }
.orn-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-light);
  background: var(--content-bg);
  padding: 3px 10px;
  border-radius: 10px;
}

/* Vertical connector */
.org-v-line {
  width: 2px;
  height: 26px;
  background: #d1d1d6;
  flex-shrink: 0;
}

/* L2 row */
.org-l2-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}


.org-dept-card {
  background: var(--card-bg);
  border: 1px solid #d1d1d6;
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 158px;
  max-width: 185px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.org-dept-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.1); border-color: #b0b0b5; }
.org-dept-card.selected { border-color: var(--accent); background: #fff8f4; }

.odc-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.35;
  margin-bottom: 4px;
}
.odc-head { font-size: 10px; color: var(--text-mid); margin-bottom: 1px; }
.odc-role { font-size: 9px; color: var(--text-light); margin-bottom: 4px; }
.odc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  border-top: 1px solid #f2f2f7;
  padding-top: 5px;
}
.odc-count { font-size: 10px; color: var(--text-light); display: flex; align-items: center; gap: 3px; }
.odc-chevron { font-size: 8px; color: var(--text-light); }
.org-dept-card.selected .odc-chevron { color: var(--accent); }

/* L3 section (inside wrapper column) */
.org-l3-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.org-sub-card {
  background: var(--card-bg);
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 140px;
  max-width: 170px;
}
.osc-name { font-size: 11px; font-weight: 600; color: var(--text-dark); line-height: 1.3; margin-bottom: 3px; }
.osc-head { font-size: 10px; color: var(--text-mid); margin-bottom: 1px; }
.osc-role { font-size: 9px; color: var(--text-light); }
.osc-count { margin-top: 4px; font-size: 10px; color: var(--text-light); display: flex; align-items: center; gap: 3px; }

/* ────────────────────────────────────────────
   РОАДМАП (Kanban + Detail + Edit)
───────────────────────────────────────────── */
.rm-page {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--content-bg);
  overflow: hidden;
}

/* ── Board header ── */
.rm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  background: #fff;
  border-bottom: 1px solid #e5e5ea;
  flex-shrink: 0;
}

.rm-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rm-page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
}

.rm-page-sub {
  font-size: 11px;
  color: var(--text-light);
}

.rm-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  color: var(--text-mid);
}

.rm-legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.rm-legend-dot.done { background: #34c759; }
.rm-legend-dot.wip  { background: #007aff; }
.rm-legend-dot.plan { background: #c7c7cc; }

/* ── Board ── */
.rm-board {
  flex: 1;
  display: flex;
  overflow: hidden;
  padding: 16px;
  gap: 12px;
}

.rm-col {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  background: #ebebf0;
  border-radius: 12px;
  overflow: hidden;
}

.rm-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
}

.rm-col-done .rm-col-header { background: #e8f9ed; }
.rm-col-wip  .rm-col-header { background: #e3eeff; }
.rm-col-plan .rm-col-header { background: #f0f0f5; }

.rm-col-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.rm-col-dot.done { background: #34c759; }
.rm-col-dot.wip  { background: #007aff; }
.rm-col-dot.plan { background: #c7c7cc; }

.rm-col-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dark);
  flex: 1;
}

.rm-col-count {
  font-size: 10px;
  font-weight: 700;
  background: rgba(0,0,0,0.08);
  color: var(--text-mid);
  border-radius: 10px;
  padding: 1px 7px;
}

.rm-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Cards ── */
.rm-card {
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
  position: relative;
}
.rm-card:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.10);
  border-color: #c7c7cc;
  transform: translateY(-1px);
}

.rm-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.rm-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.3;
}

.rm-ver {
  font-size: 9px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.rm-ver-lg {
  font-size: 11px;
  padding: 2px 8px;
}

.rm-card-desc {
  font-size: 11px;
  color: var(--text-light);
  line-height: 1.4;
  margin-bottom: 5px;
}

.rm-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 5px;
}

.rm-chip {
  font-size: 10px;
  font-weight: 500;
  border-radius: 5px;
  padding: 2px 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.rm-chip-dl   { background: #f0f8ff; color: #2a6ec4; }
.rm-chip-cost { background: #f5f8e8; color: #5a7a10; }

.rm-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.rm-tag {
  font-size: 9px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: 0.2px;
}

.rm-card-arrow {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: 12px;
  color: #c7c7cc;
  transition: color 0.15s, right 0.15s;
}
.rm-card:hover .rm-card-arrow { color: var(--accent); right: 7px; }

/* ══════════════════════════════════════
   DETAIL VIEW
══════════════════════════════════════ */
.rm-detail-page { overflow: hidden; }

.rm-detail-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e5ea;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.rm-back-btn { flex-shrink: 0; }

.rm-detail-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rm-detail-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
}

.rm-col-badge {
  font-size: 10px;
  font-weight: 700;
  border-radius: 5px;
  padding: 2px 8px;
  letter-spacing: 0.3px;
}
.rm-col-badge-done { background: #d1f0db; color: #2a7a3b; }
.rm-col-badge-wip  { background: #dceeff; color: #0a5cb4; }
.rm-col-badge-plan { background: #ebebf0; color: #48484a; }

.rm-detail-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.rm-edit-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mid);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.rm-edit-btn:hover { border-color: var(--accent); color: var(--accent); }

.rm-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.rm-add-btn:hover { opacity: 0.85; }

.modal-btn-delete {
  background: none;
  border: 1px solid #ffb3b3;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 12px;
  color: #c0392b;
  cursor: pointer;
  transition: background 0.15s;
}
.modal-btn-delete:hover { background: #fff0f0; }

.rm-detail-desc {
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text-mid);
  background: #fafafa;
  border-bottom: 1px solid #e5e5ea;
  flex-shrink: 0;
}

/* ── 3 stages ── */
.rm-stages {
  flex: 1;
  display: flex;
  gap: 0;
  overflow: hidden;
  padding: 16px;
  gap: 12px;
}

.rm-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  background: #f9f9fb;
  border: 1px solid #e5e5ea;
}

.rm-stage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e5ea;
  flex-shrink: 0;
}

.rm-stage-was  .rm-stage-header { background: #fff8f0; }
.rm-stage-is   .rm-stage-header { background: #f0fff4; }
.rm-stage-plan .rm-stage-header { background: #f0f4ff; }

.rm-stage-icon  { font-size: 16px; }
.rm-stage-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dark);
}

.rm-stage-body {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.6;
  overflow-y: auto;
  flex: 1;
  white-space: pre-wrap;
}

.rm-stage-empty { color: #c7c7cc; font-style: italic; font-size: 12px; }

/* ══════════════════════════════════════
   EDIT MODAL
══════════════════════════════════════ */
.rm-modal-box {
  width: 680px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.rm-modal-body {
  overflow-y: auto;
  flex: 1;
  gap: 12px;
}

.rm-form-row {
  display: flex;
  gap: 12px;
}

.rm-form-col { flex: 1; }
.rm-form-col-sm { flex: 0 0 120px; }

.rm-textarea {
  resize: vertical;
  min-height: 72px;
  font-size: 12px;
  line-height: 1.5;
}

.rm-stage-inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid #e5e5ea;
  padding-top: 12px;
  margin-top: 4px;
}

.rm-stage-lbl { margin-bottom: 4px !important; }
.rm-stage-lbl-was  { color: #c45a00 !important; }
.rm-stage-lbl-is   { color: #2a7a3b !important; }
.rm-stage-lbl-plan { color: #0a5cb4 !important; }

/* ── Placeholder pages ── */
.placeholder-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
  font-size: 14px;
  flex-direction: column;
  gap: 8px;
}

/* ── Login Overlay ── */
#loginOverlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: linear-gradient(135deg, #0c0c0c 0%, #181818 60%, #0e0e0e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #1c1c1c;
  border: 1px solid #2e2e2e;
  border-radius: 18px;
  padding: 44px 52px;
  width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 24px 64px rgba(0,0,0,.7);
}
.login-logo {
  width: 54px;
  height: 54px;
  background: #000;
  border-radius: 14px;
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
}
.login-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 5px;
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 11px;
  color: #444;
  letter-spacing: 3px;
  margin-bottom: 36px;
  text-transform: uppercase;
}
.login-field {
  width: 100%;
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 9px;
  padding: 13px 16px;
  color: #ddd;
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
  font-family: var(--font);
  transition: border-color .2s;
  display: block;
}
.login-field:focus { border-color: var(--accent); }
.login-btn {
  width: 100%;
  background: linear-gradient(135deg, #e07b2f, #c4621a);
  border: none;
  border-radius: 9px;
  padding: 14px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 1px;
  margin-top: 6px;
  transition: opacity .2s;
  font-family: var(--font);
}
.login-btn:hover  { opacity: .85; }
.login-btn:disabled { opacity: .45; cursor: default; }
.login-error {
  color: #ff5a5a;
  font-size: 13px;
  margin-top: 14px;
  min-height: 18px;
  text-align: center;
}
.placeholder-page span { font-size: 32px; }

/* CEO-сводка: спиннер загрузки */
@keyframes ceospin { to { transform: rotate(360deg); } }
.ceo-spin { display: inline-block; animation: ceospin 1s linear infinite; }

/* ── CEO-сводка — layout ── */
.ceo-page {
  padding: 28px;
  max-width: 1000px;
  margin: 0 auto;
}
.ceo-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 12px;
}
.ceo-header-btns {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* ── CEO-сводка — mobile ── */
@media (max-width: 640px) {
  .ceo-page { padding: 12px 10px; }
  .ceo-header { flex-direction: column; gap: 10px; }
  .ceo-header h2 { font-size: 18px !important; }
  .ceo-header-btns { width: 100%; justify-content: flex-end; }
  .ceo-header-btns .login-btn { padding: 7px 14px !important; font-size: 13px !important; }
}

/* ── CEO-сводка — плашка источника внутри карточки инсайта ── */
.ceo-src-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 9px;
}
.ceo-src-lbl { font-size: 11px; color: var(--text-light); }
.ceo-src-chip {
  display: inline-block; font-size: 11px; line-height: 1.2;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(0,0,0,.05); border: 1px solid rgba(0,0,0,.08);
  color: var(--text-dark); text-decoration: none; white-space: nowrap;
}
.ceo-src-chip-link { cursor: pointer; transition: background .15s, border-color .15s; }
.ceo-src-chip-link:hover { background: rgba(0,0,0,.09); border-color: var(--accent); }
