/* Бесшовный экран оргструктуры: верхняя панель приложения остаётся на месте. */
.org-structure-screen {
  --surface-color: var(--panel-bg, #fff);
  --bg-color: var(--bg-canvas, #fff);
  --border-color: var(--panel-border, #d8dde4);
  --text-primary: var(--main-text-color, #1f2937);
  --text-secondary: var(--icon, #718096);
  --danger-color: #dc3545;
  --success-color: #28a745;
  height: calc(100vh - var(--org-appbar-height, 53px));
  min-height: 0;
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
  background-color: var(--bg-canvas);
  background-image: radial-gradient(circle, var(--grid-dot) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
}
.org-structure-screen[hidden] { display: none !important; }
body.org-structure-open .main-content { display: none !important; }
body.org-structure-open { overflow: hidden; }
body.org-structure-open header.appbar { position: sticky; top: 0; flex: 0 0 auto; }
body.org-structure-open header.appbar > *:not(.left):not(.org-screen-toolbar):not(.button-group--no-border):not(.right) {
  display: none !important;
}
body.org-structure-open header.appbar > .left,
body.org-structure-open header.appbar > .right,
body.org-structure-open header.appbar > .button-group--no-border { flex: 0 0 auto; }
body.org-structure-open header.appbar > .button-group--no-border {
  margin-left: 0 !important;
  margin-right: 0;
}
body.org-structure-open header.appbar #btn-assistant { display: none !important; }
#btn-org-structure.is-active { background: rgba(74,158,255,.18) !important; color: #7db8f5 !important; }

.org-screen-toolbar {
  --surface-color: var(--appbar-bg-color, #252b34);
  --bg-color: var(--main-bg-color, #171b21);
  --border-color: var(--button-group-border-color, #46505e);
  --text-primary: var(--main-text-color, #e7ebf0);
  --text-secondary: #8e99a7;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  box-sizing: border-box;
  background: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  z-index: 20;
}
body.org-structure-open header.appbar > .org-screen-toolbar {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  height: 40px;
  gap: 10px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
body.org-structure-open header.appbar .org-screen-toolbar .org-screen-title { min-width: 122px; }
body.org-structure-open header.appbar .org-screen-toolbar .oc-search {
  width: clamp(230px, 27vw, 380px);
  max-width: none;
  flex: 0 1 380px;
}
body.org-structure-open header.appbar .org-screen-toolbar .org-screen-tools {
  min-width: 0;
  gap: 5px;
}
body.org-structure-open header.appbar .org-screen-toolbar .oc-tool-btn {
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  color: var(--main-text-color);
  border-radius: 50%;
}
body.org-structure-open header.appbar .org-screen-toolbar .oc-tool-btn-icon {
  width: 36px;
  padding: 0;
  color: var(--main-text-color);
  background: transparent;
  border: 0;
  box-shadow: none;
}
body.org-structure-open header.appbar .org-screen-toolbar .oc-tool-btn-icon:hover,
body.org-structure-open header.appbar .org-screen-toolbar .oc-tool-btn-icon.active {
  color: #287fd5;
  background: rgba(40,127,213,.11);
  border: 0;
  box-shadow: none;
  transform: none;
}
body.org-structure-open header.appbar .org-screen-toolbar .oc-tool-primary {
  color: #fff;
  background: #287fd5;
  border: 0;
  border-radius: 18px;
}
body.org-structure-open header.appbar .org-screen-toolbar .oc-tool-primary:hover { background: #1f70bf; }
.org-screen-title { display: inline-flex; align-items: center; gap: 7px; min-width: 150px; }
.org-screen-title strong { font-size: 15.5px; font-weight: 650; letter-spacing: .01em; }
.oc-structure-select {
  width: clamp(130px, 15vw, 220px); height: 32px; min-width: 0; padding: 0 28px 0 10px;
  color: var(--main-text-color); background: rgba(255,255,255,.07); border: 1px solid var(--button-group-border-color, #46505e);
  border-radius: 9px; outline: none; font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.oc-structure-select:focus { border-color: #4a9eff; box-shadow: 0 0 0 2px rgba(74,158,255,.15); }
.oc-structure-select option { color: #1f2937; background: #fff; }
.oc-structure-add {
  appearance: none; width: 28px; height: 28px; flex: 0 0 28px; display: inline-grid; place-items: center;
  padding: 0; color: var(--text-secondary); background: transparent; border: 0; border-radius: 7px; cursor: pointer;
}
.oc-structure-add:hover { color: #4a9eff; background: rgba(74,158,255,.12); }
.oc-structure-add .material-symbols-outlined { font-size: 18px; }
.org-screen-tools { margin-left: auto; display: flex; align-items: center; gap: 7px; }

.oc-breadcrumbs {
  min-height: 38px; box-sizing: border-box; display: flex; align-items: center; gap: 3px; padding: 5px 18px;
  background: color-mix(in srgb,var(--surface-color) 96%,transparent); border-bottom: 1px solid var(--border-color); z-index: 18;
}
.oc-breadcrumbs[hidden] { display: none !important; }
.oc-breadcrumb {
  appearance: none; max-width: 260px; padding: 5px 8px; overflow: hidden; color: var(--text-secondary);
  background: transparent; border: 0; border-radius: 7px; font: inherit; font-size: 11.5px; font-weight: 600;
  text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.oc-breadcrumb:hover { color: #4a9eff; background: rgba(74,158,255,.10); }
.oc-breadcrumb:disabled { color: var(--text-primary); cursor: default; opacity: 1; }
.oc-breadcrumb:disabled:hover { background: transparent; }
.oc-breadcrumb-separator { color: var(--text-secondary); font-size: 16px; opacity: .6; }

.oc-view { position: relative; flex: 1; min-height: 0; display: flex; overflow: hidden; }
.oc-view-update-overlay {
  position: absolute !important; inset: 0; z-index: 27; width: auto !important; height: auto !important;
  pointer-events: none !important; opacity: 1; transition: opacity .18s ease-out;
}
.oc-view-update-overlay.is-leaving { opacity: 0; }
.oc-view-update-overlay * { pointer-events: none !important; }
.oc-zoom-controls {
  position: absolute; left: 16px; bottom: 16px; z-index: 28;
  display: flex; align-items: center; gap: 2px; padding: 4px;
  color: var(--main-text-color); background: color-mix(in srgb,var(--panel-bg) 96%,transparent);
  border: 0; border-radius: 12px; box-shadow: 0 6px 22px rgba(0,0,0,.18);
}
.oc-zoom-btn {
  appearance: none; min-width: 29px; height: 29px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--main-text-color); background: transparent; border: 0; border-radius: 8px;
  font: inherit; font-size: 10.5px; font-weight: 700; cursor: pointer;
}
.oc-zoom-btn .material-symbols-outlined { font-size: 17px; }
.oc-zoom-btn:hover { color: #287fd5; background: rgba(40,127,213,.12); }
.oc-zoom-btn:disabled { opacity: .35; cursor: default; }
.oc-zoom-btn:disabled:hover { color: var(--main-text-color); background: transparent; }
.oc-zoom-reset { min-width: 45px; }
[data-theme=light] .oc-zoom-controls { background: rgba(255,255,255,.96); box-shadow: 0 6px 22px rgba(31,41,55,.15); }
[data-theme=dark] .oc-zoom-controls { background: rgba(32,32,32,.97); box-shadow: 0 8px 26px rgba(0,0,0,.36); }
.oc-canvas {
  flex: 1; min-width: 0; overflow: auto; padding: 18px 60px 90px;
  display: flex; justify-content: center; justify-content: safe center; align-items: flex-start;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(circle, var(--grid-dot) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  scrollbar-width: none; cursor: grab; touch-action: none;
}
.oc-canvas::-webkit-scrollbar { display: none; }
.oc-canvas.is-panning, .oc-table-scroll.is-panning { cursor: grabbing; }
body.oc-canvas-panning, body.oc-canvas-panning * { user-select: none !important; }
.oc-canvas[hidden], .oc-table-view[hidden] { display: none !important; }
.oc-state { min-width: 300px; text-align: center; padding: 80px 20px; color: var(--text-secondary); font-size: 14px; }
.oc-state .material-symbols-outlined { display: block; margin-bottom: 12px; font-size: 46px; opacity: .45; }

/* Карточное дерево: геометрия перенесена из эталонной desktop-версии. */
.org-tree { display: inline-block; min-width: max-content; }
.org-tree ul {
  list-style: none; margin: 0; padding: 36px 0 0; display: flex; flex-wrap: nowrap;
  justify-content: center; position: relative;
}
.org-tree > ul { padding-top: 0; }
.org-tree li {
  list-style: none; position: relative; display: flex; flex-direction: column;
  align-items: center; padding: 0 12px;
}
.org-tree li::before, .org-tree li::after { display: none; }
.oc-parent-line {
  position: absolute; top: 0; left: 50%; margin-left: -1px; width: 0; height: 36px;
  border-left: 2px solid var(--border-color); z-index: 0;
}
.org-tree > ul > .oc-parent-line { display: none; }
.oc-conn-row {
  display: flex; margin: 0 -14px; align-self: stretch; height: 36px;
  align-items: flex-start; flex-shrink: 0;
}
.oc-h-seg { flex: 1; height: 100%; border-top: 2px solid var(--border-color); }
.oc-h-seg.oc-h-invis { border-top-color: transparent; }
.oc-h-first-right { border-top-left-radius: 6px; border-left: 2px solid var(--border-color); }
.oc-h-last-left { border-top-right-radius: 6px; border-right: 2px solid var(--border-color); }
.oc-v-seg { width: 0; height: 100%; border-left: 2px solid var(--border-color); flex-shrink: 0; }
.oc-v-corner { border-left: 0 !important; }

.oc-node-wrap { display: grid; grid-template-columns: 1fr auto 1fr; }
.oc-node-wrap > .oc-card { grid-column: 2 / 3; grid-row: 1; }
.oc-node-wrap > .oc-emp-container { grid-column: 2 / 4; grid-row: 2; }
.oc-emp-item .oc-node-wrap { display: flex; flex-direction: column; align-items: flex-start; }
.oc-emp-item .oc-node-wrap > .oc-card,
.oc-emp-item .oc-node-wrap > .oc-emp-container { grid-column: auto; grid-row: auto; }

.oc-card {
  position: relative; width: 230px; box-sizing: border-box; padding: 14px 15px 12px;
  color: var(--text-primary); text-align: left; background: var(--surface-color);
  border: 1px solid var(--border-color); border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
  transition: width .3s ease, font-size .3s ease, color .3s ease, border-color .2s, box-shadow .2s, opacity .15s;
  animation: oc-appear .22s ease-out both;
}
.oc-card.no-anim, .oc-emp-item .oc-card { animation: none !important; }
.oc-card-emp { width: 200px; min-width: 0; padding: 10px 12px; background: var(--bg-color); border-style: dashed; }
.oc-card-emp.oc-card-has-branch { cursor: pointer; padding-bottom: 25px; }
.oc-member-branch-toggle {
  position: absolute; right: 9px; bottom: 6px; display: grid; width: 20px; height: 20px;
  place-items: center; color: var(--text-secondary); background: color-mix(in srgb,var(--surface-color) 70%,transparent);
  border-radius: 6px; pointer-events: none; transition: transform .2s ease, color .2s ease;
}
.oc-member-branch-toggle .material-symbols-outlined { font-size: 18px; }
.oc-card-emp.is-collapsed .oc-member-branch-toggle { transform: rotate(-90deg); }
.oc-card-emp.oc-card-has-branch:hover .oc-member-branch-toggle { color: var(--text-primary); }
.oc-card[draggable=true] { cursor: grab; }
.oc-card[draggable=true]:active { cursor: grabbing; }
.oc-card:hover { border-color: color-mix(in srgb, var(--border-color) 55%, #4a9eff 45%); box-shadow: 0 7px 20px rgba(0,0,0,.16); }
.oc-hide-lines::before, .oc-hide-lines::after { display: none !important; }
.oc-ghost-hide { opacity: 0 !important; }
.oc-card.oc-drag-over {
  border-color: #10b981 !important; background: rgba(16,185,129,.07) !important;
  box-shadow: 0 0 0 3px rgba(16,185,129,.24) !important;
}
.oc-card.oc-drag-over-emp { outline: 2px dashed #2563eb; outline-offset: 2px; box-shadow: 0 0 0 4px rgba(37,99,235,.18); }
.oc-card.oc-drop-department {
  outline: 2px solid #7c6fca; outline-offset: 2px;
  background: color-mix(in srgb,var(--surface-color) 78%,#7c6fca 22%);
  box-shadow: 0 0 0 5px rgba(124,111,202,.18);
}
.oc-card.oc-drop-before::before, .oc-card.oc-drop-after::after {
  content: ''; position: absolute; top: -10px; bottom: -10px; width: 3px;
  background: #4a9eff; border-radius: 2px; z-index: 8;
}
.oc-card.oc-drop-before::before { left: -16px; }
.oc-card.oc-drop-after::after { right: -16px; }
.oc-drop-split { position: absolute; inset: 0; display: flex; overflow: hidden; border-radius: inherit; pointer-events: none; z-index: 4; }
.oc-drop-split > div { flex: 1 1 50%; opacity: 0; transition: opacity .08s ease; }
.oc-drop-split-left { background: rgba(37,99,235,.32); }
.oc-drop-split-right { background: rgba(34,197,94,.32); }
.oc-card.oc-drop-head .oc-drop-split-left,
.oc-card.oc-drop-member .oc-drop-split-right { opacity: 1; }
.oc-card.oc-drop-member-full .oc-drop-split-left,
.oc-card.oc-drop-member-full .oc-drop-split-right { opacity: 1; background: rgba(34,197,94,.32); }
.oc-card.oc-drop-head { outline: 2px solid #2563eb; outline-offset: 1px; }
.oc-card.oc-drop-member, .oc-card.oc-drop-member-full { outline: 2px solid #22c55e; outline-offset: 1px; }

.oc-card-dept-label {
  margin-bottom: 10px; overflow: hidden; color: var(--text-secondary); font-size: 11px;
  font-weight: 750; letter-spacing: .5px; text-transform: uppercase; text-overflow: ellipsis; white-space: nowrap;
}
.oc-card-person { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.oc-avatar, .oc-avatar-init {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%; object-fit: cover;
  background: #4a9eff; color: #fff; border: 1px solid rgba(0,0,0,.08);
}
.oc-avatar-shell {
  display: inline-grid; flex: 0 0 auto; overflow: hidden; place-items: center;
  border-radius: 50%; vertical-align: middle;
}
.oc-avatar-shell > .oc-avatar,
.oc-avatar-shell > .oc-avatar-init { grid-area: 1 / 1; }
.oc-avatar { user-select: none; -webkit-user-drag: none; }
/* Search results live inside header.appbar buttons. Keep employee photos out of
   the global toolbar-icon recolouring rules from style_landscape.css. */
body.org-structure-open header.appbar .oc-search-item .oc-avatar-shell > .oc-avatar {
  width: 100% !important; height: 100% !important; margin: 0 !important;
  object-fit: cover; filter: none !important; opacity: 1 !important;
}
.oc-avatar-init { display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 750; }
.oc-avatar-init .material-symbols-outlined { color: var(--text-secondary); font-size: 20px; }
.oc-card-name-wrap { flex: 1; min-width: 0; }
.oc-card-name { overflow: hidden; color: var(--text-primary); font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.oc-card-no-head { color: var(--text-secondary); font-size: 12px; font-style: italic; }
.oc-card-role {
  margin-bottom: 8px; padding-left: 48px; overflow: hidden; color: var(--text-secondary);
  font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap;
}
.oc-card-emp .oc-card-role { margin-bottom: 0; padding-left: 0; }
.oc-deputy-branch {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 5px; padding: 3px 6px;
  color: #6d5fc0; background: rgba(124,111,202,.12); border: 0; border-radius: 6px;
  font: inherit; font-size: 10px; font-weight: 700; cursor: pointer;
}
.oc-deputy-branch .material-symbols-outlined { font-size: 14px; }
.oc-deputy-branch:hover { color: #5545ad; background: rgba(124,111,202,.2); }
[data-theme=dark] .oc-deputy-branch { color: #aaa0ea; background: rgba(124,111,202,.18); }
.oc-detail-setting {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px;
  color: var(--text-primary); background: color-mix(in srgb,var(--surface-color) 78%,#6b7783 22%);
  border: 1px solid var(--border-color); border-radius: 10px; cursor: pointer;
}
.oc-detail-setting input { margin-top: 3px; accent-color: #6b7783; }
.oc-detail-setting span { display: grid; gap: 3px; }
.oc-detail-setting b { font-size: 12px; }
.oc-detail-setting small { color: var(--text-secondary); font-size: 11px; line-height: 1.35; }
.oc-badge { display: inline-block; margin-top: 3px; padding: 2px 7px; border-radius: 20px; font-size: 9px; font-weight: 650; }
.oc-badge-admin { color: #dc3545; background: rgba(220,53,69,.15); }
.oc-badge-executor { color: #4a9eff; background: rgba(74,158,255,.12); }
.oc-badge-position {
  max-width: 100%; overflow: hidden; color: #3d8bd2; background: rgba(74,158,255,.11);
  text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}
[data-theme=dark] .oc-badge-position { color: #7eb9ef; background: rgba(74,158,255,.15); }
.oc-card-stats { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 9px; border-top: 1px solid var(--border-color); }
.oc-stat {
  appearance: none; display: flex; align-items: center; gap: 3px; padding: 2px 5px;
  color: var(--text-secondary); background: transparent; border: 0; border-radius: 5px;
  font: inherit; font-size: 11.5px; cursor: pointer;
}
.oc-stat:hover { background: var(--bg-color); color: var(--text-primary); }
.oc-stat:not(button) { cursor: default; opacity: .82; }
.oc-stat:not(button):hover { color: var(--text-secondary); background: transparent; }
.oc-stat.oc-stat-on { color: #4a9eff; font-weight: 650; }
.oc-stat .material-symbols-outlined { font-size: 14px; }

.oc-card-actions {
  position: absolute; top: 7px; right: 7px; z-index: 20; display: none; gap: 1px;
  padding: 3px; background: var(--surface-color); border: 1px solid var(--border-color);
  border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.oc-card:hover .oc-card-actions, .oc-card:focus-within .oc-card-actions { display: flex; }
.oc-act-icon {
  appearance: none; width: 25px; height: 25px; display: grid; place-items: center; padding: 0;
  color: var(--text-secondary); background: transparent; border: 0; border-radius: 5px; cursor: pointer;
}
.oc-act-icon .material-symbols-outlined { font-size: 16px; }
.oc-act-icon:hover { color: var(--text-primary); background: var(--bg-color); }
.oc-act-icon.success { color: var(--success-color); }
.oc-act-icon.danger:hover { color: var(--danger-color); background: rgba(220,53,69,.10); }
.oc-act-detail:hover, .oc-table-detail-action:hover { background: color-mix(in srgb,#6b7783 15%,transparent); }
.oc-process-detail-glyph {
  display: block; width: 17px; height: 17px; background: #6b7783;
  -webkit-mask: url(svg/from-square.svg) center/contain no-repeat;
  mask: url(svg/from-square.svg) center/contain no-repeat;
}
.oc-table-detail-action .oc-process-detail-glyph { width: 18px; height: 18px; }

/* Вертикальная смешанная ветвь сотрудников и вложенных подразделений. */
.oc-emp-container { position: relative; width: 100%; display: flex; flex-direction: column; align-items: flex-start; }
.oc-emp-panel {
  z-index: 1; display: flex; flex-direction: column; margin-left: 36px; padding: 12px 0 0;
  animation: oc-slide-down .28s ease-out both;
}
.oc-emp-item { position: relative; display: flex; padding-left: 20px; margin-bottom: 8px; animation: oc-fade-in .22s ease both; }
.oc-emp-item:last-child { margin-bottom: 0; }
.oc-emp-item::after {
  content: ''; position: absolute; left: 0; top: 0; height: calc(100% + 8px);
  border-left: 2px solid var(--border-color); box-sizing: border-box;
}
.oc-emp-item:first-child::after { top: -12px; height: calc(100% + 20px); }
.oc-emp-item:last-child::after { display: none; }
.oc-emp-item .oc-card::before {
  content: ''; position: absolute; left: -21px; top: 0; width: 20px; height: 50%;
  border-bottom: 2px solid var(--border-color); box-sizing: border-box; z-index: 1;
}
.oc-emp-item:last-child .oc-card::before { display: none; }
.oc-emp-item:last-child .oc-card::after {
  content: ''; position: absolute; left: -21px; top: -1px; width: 20px; height: calc(50% + 1px);
  border-left: 2px solid var(--border-color); border-bottom: 2px solid var(--border-color);
  border-bottom-left-radius: 6px; box-sizing: border-box; z-index: 1;
}
.oc-emp-item:first-child:last-child .oc-card::after { top: -13px; height: calc(50% + 13px); }
.oc-card.oc-dragging::before, .oc-card.oc-dragging::after { display: none !important; }
.oc-emp-cardrow { display: flex; align-items: center; }

@keyframes oc-appear { from { opacity: 0; transform: scale(.88) translateY(-6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes oc-fade-in { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes oc-slide-down { from { opacity: 0; transform: scaleY(.55) translateY(-10px); transform-origin: top; } to { opacity: 1; transform: scaleY(1) translateY(0); transform-origin: top; } }
@keyframes oc-spin { to { transform: rotate(360deg); } }

/* Верхний поиск и инструменты. */
.oc-search { position: relative; width: 390px; max-width: 34vw; }
.oc-search-input {
  width: 100%; height: 36px; box-sizing: border-box; padding: 9px 34px 9px 36px;
  color: var(--main-text-color); background: rgba(255,255,255,.08); border: 0;
  border-radius: 18px; outline: none; overflow: hidden; resize: none;
  font: inherit; font-size: 12.5px; line-height: 18px; white-space: nowrap;
  box-shadow: none; transition: background .16s ease, box-shadow .16s ease;
}
.oc-search-input::placeholder { color: var(--text-secondary); }
.oc-search-input:focus { background: rgba(255,255,255,.13); box-shadow: 0 0 0 2px rgba(74,158,255,.16); }
[data-theme=light] body.org-structure-open .oc-search-input {
  color: #263341; background: rgba(255,255,255,.72);
  box-shadow: 0 1px 5px rgba(25,39,52,.10);
}
[data-theme=light] body.org-structure-open .oc-search-input:focus {
  background: #fff; box-shadow: 0 0 0 2px rgba(40,127,213,.14), 0 2px 8px rgba(25,39,52,.10);
}
[data-theme=dark] body.org-structure-open .oc-search-input {
  color: #eef2f6; background: rgba(255,255,255,.07);
}
[data-theme=dark] body.org-structure-open .oc-search-input:focus {
  background: rgba(255,255,255,.11); box-shadow: 0 0 0 2px rgba(74,158,255,.18);
}
.oc-search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); font-size: 19px; pointer-events: none; }
.oc-search-clear {
  appearance: none; position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 26px; min-width: 26px; height: 26px; padding: 0; display: inline-flex;
  align-items: center; justify-content: center; color: var(--text-secondary);
  background: transparent; border: 0; border-radius: 50%; cursor: pointer;
}
.oc-search-clear[hidden] { display: none !important; }
.oc-search-clear:hover { color: var(--text-primary); background: rgba(127,138,150,.14); }
.oc-search-clear .material-symbols-outlined { font-size: 17px !important; }
body.org-structure-open header.appbar .oc-search-clear {
  width: 26px; min-width: 26px; height: 26px; padding: 0; border: 0; background: transparent;
}
body.org-structure-open header.appbar .oc-search-clear:hover { background: rgba(127,138,150,.14); }
.oc-search-results {
  position: absolute; top: calc(100% + 7px); left: 0; right: 0; z-index: 100;
  max-height: 360px; overflow: auto; padding: 6px; color: var(--main-text-color);
  background: var(--panel-bg); border: 0; border-radius: 12px; box-shadow: 0 14px 38px rgba(0,0,0,.24);
}
.oc-search-results[hidden] { display: none; }
.oc-search-item {
  appearance: none; width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 9px;
  color: var(--text-primary); background: transparent; border: 0; border-radius: 9px; cursor: pointer; text-align: left;
}
.oc-search-item:hover { background: rgba(74,158,255,.12); }
.oc-search-item-department { background: rgba(74,158,255,.055); }
.oc-search-result-kind {
  flex: 0 0 auto; color: #4a9eff; font-size: 18px !important;
}
.oc-search-meta { min-width: 0; flex: 1; }
.oc-search-name, .oc-search-role { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-search-name { margin: 0; padding: 0; font-size: 12px; font-weight: 650; }
.oc-search-role { margin-top: 2px; color: var(--text-secondary); font-size: 10.5px; }
.oc-search-empty { padding: 13px; color: var(--text-secondary); font-size: 12px; text-align: center; }
.oc-match {
  padding: 0; color: #287fd5; background: rgba(74,158,255,.20);
  border-radius: 3px; font-weight: 760;
}
body.org-structure-open header.appbar .oc-search-item {
  width: 100%; min-width: 0; height: auto; min-height: 0; padding: 8px 9px;
  justify-content: flex-start; gap: 10px; color: var(--main-text-color);
  background: transparent; border: 0; border-radius: 9px; white-space: normal;
}
body.org-structure-open header.appbar .oc-search-item:hover { background: rgba(74,158,255,.12); }
body.org-structure-open header.appbar .oc-search-item-department {
  background: rgba(74,158,255,.055);
}
body.org-structure-open header.appbar .oc-search-item-department:hover {
  background: rgba(74,158,255,.14);
}
[data-theme=light] body.org-structure-open header.appbar .oc-search-results {
  color: #263341; background: #f1f5f9;
}
[data-theme=light] body.org-structure-open header.appbar .oc-search-name { color: #263341; }
[data-theme=light] body.org-structure-open header.appbar .oc-search-role { color: #718096; }
[data-theme=dark] body.org-structure-open header.appbar .oc-search-name { color: #f4f4f4; }
[data-theme=dark] body.org-structure-open header.appbar .oc-search-role { color: #a0a8b2; }
@keyframes org-search-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1000px rgba(249,115,22,0), 0 0 0 2px rgba(249,115,22,.25); }
  50% { box-shadow: inset 0 0 0 1000px rgba(249,115,22,.12), 0 0 0 2px rgba(249,115,22,1); }
}
.org-tree .oc-card.oc-search-highlight {
  animation: org-search-pulse 1.6s infinite ease-in-out !important;
  z-index: 24;
}
@keyframes org-search-table-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1000px rgba(249,115,22,0); }
  50% { box-shadow: inset 0 0 0 1000px rgba(249,115,22,.14); }
}
.oc-structure-table .oc-table-row.oc-search-highlight td {
  animation: org-search-table-pulse 1.6s infinite ease-in-out !important;
}
.oc-structure-table .oc-table-row.oc-search-highlight td:first-child { box-shadow: inset 2px 0 #f97316; }

.oc-tool-btn {
  appearance: none; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 0 12px; color: var(--text-primary); background: var(--surface-color);
  border: 1px solid var(--border-color); border-radius: 10px; cursor: pointer;
  font: inherit; font-size: 11.5px; font-weight: 650;
}
.oc-tool-btn:hover, .oc-tool-btn.active { color: #4a9eff; border-color: #4a9eff; background: rgba(74,158,255,.10); }
.oc-tool-btn .material-symbols-outlined { font-size: 18px; }
.oc-tool-btn-icon { width: 36px; padding: 0; border: 0; background: transparent; box-shadow: none; }
.oc-tool-btn-icon:hover, .oc-tool-btn-icon.active {
  color: #287fd5; background: rgba(40,127,213,.11); border-color: transparent;
  box-shadow: none; transform: none;
}
.oc-tool-primary { color: #fff; background: #287fd5; border-color: transparent; }
.oc-tool-primary:hover { color: #fff; background: #1f70bf; }
.oc-screen-close:hover { color: #fff; background: #d74646; border-color: #d74646; }
.oc-danger-btn { color: #ef6262; }

/* Правый редактор — часть экрана, без модального backdrop. */
.oc-editor-drawer {
  position: absolute; top: 12px; right: 12px; bottom: 12px; z-index: 30; width: min(390px, 36vw);
  display: flex; flex-direction: column; overflow: hidden; background: var(--surface-color);
  border: 1px solid var(--border-color); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.32);
  animation: oc-drawer-in .24s cubic-bezier(.16,1,.3,1);
}
.oc-editor-drawer[hidden] { display: none; }
@keyframes oc-drawer-in { from { opacity: 0; transform: translateX(22px); } to { opacity: 1; transform: none; } }
.oc-editor-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border-color); }
.oc-editor-head h3 { margin: 0 auto 0 0; font-size: 14px; }
.oc-editor-body { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 13px; padding: 15px; }
.oc-form-field { display: flex; flex-direction: column; gap: 6px; color: var(--text-secondary); font-size: 11px; font-weight: 650; }
.oc-form-hint { color: var(--text-secondary); font-size: 11px; line-height: 1.45; }
.oc-structure-danger { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border-color); }
.oc-form-input {
  width: 100%; height: 40px; box-sizing: border-box; padding: 0 11px; color: var(--text-primary);
  background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 9px; outline: none; font: inherit; font-size: 12px;
}
.oc-form-search {
  padding: 11px; overflow: hidden; resize: none; line-height: 16px; white-space: nowrap;
}
.oc-form-input:focus { border-color: #4a9eff; box-shadow: 0 0 0 3px rgba(74,158,255,.13); }
.oc-editor-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; padding-top: 10px; }
.oc-current-person { display: flex; align-items: center; gap: 9px; padding: 9px; background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 10px; font-size: 12px; }
.oc-current-person > span:nth-child(2) { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-picker-results { display: flex; flex-direction: column; gap: 4px; }
.oc-picker-empty { padding: 22px 8px; color: var(--text-secondary); font-size: 11.5px; text-align: center; }
.oc-picker-person {
  appearance: none; width: 100%; display: grid; grid-template-columns: 38px minmax(0,1fr) auto;
  align-items: center; gap: 9px; padding: 8px; color: var(--text-primary); background: transparent;
  border: 0; border-radius: 9px; cursor: pointer; text-align: left;
}
.oc-picker-person:hover { background: rgba(74,158,255,.11); }
.oc-picker-person strong, .oc-picker-person small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-picker-person strong { font-size: 12px; }
.oc-picker-person small { margin-top: 3px; color: var(--text-secondary); font-size: 10px; }
.oc-picker-person > .material-symbols-outlined { color: #4a9eff; font-size: 20px; }

[data-theme=light] .oc-editor-drawer {
  color: #263341; background: #f8fafc; border-color: rgba(31,41,55,.13);
  box-shadow: 0 20px 60px rgba(31,41,55,.18);
}
[data-theme=light] .oc-editor-head { border-bottom-color: rgba(31,41,55,.10); }
[data-theme=light] .oc-form-field { color: #667384; }
[data-theme=light] .oc-form-input {
  color: #263341; background: #fff; border-color: rgba(31,41,55,.14);
  box-shadow: 0 1px 4px rgba(31,41,55,.06);
}
[data-theme=light] .oc-form-input::placeholder { color: #8a96a5; }
[data-theme=light] .oc-picker-results {
  padding: 4px; background: rgba(229,235,242,.56); border-radius: 12px;
}
[data-theme=light] .oc-picker-person {
  color: #263341; background: rgba(255,255,255,.88); box-shadow: 0 1px 4px rgba(31,41,55,.07);
}
[data-theme=light] .oc-picker-person:hover { background: #fff; box-shadow: 0 3px 10px rgba(40,127,213,.13); }
[data-theme=light] .oc-picker-person small, [data-theme=light] .oc-picker-empty { color: #667384; }

[data-theme=dark] .oc-editor-drawer { color: #f4f4f4; background: #202020; border-color: #454545; }
[data-theme=dark] .oc-form-input { color: #f4f4f4; background: #292929; border-color: #484848; }
[data-theme=dark] .oc-form-input::placeholder { color: #929292; }
[data-theme=dark] .oc-picker-results { padding: 4px; background: rgba(255,255,255,.025); border-radius: 12px; }
[data-theme=dark] .oc-picker-person { color: #f4f4f4; background: #292929; }
[data-theme=dark] .oc-picker-person:hover { background: #343434; }

.oc-style-panel {
  min-width: 200px; padding: 12px 14px; color: var(--main-text-color);
  background-color: var(--panel-bg, #fff); opacity: 1; isolation: isolate;
  border: 1px solid var(--panel-border, #d8dde4); border-radius: 12px;
  box-shadow: 0 14px 42px rgba(0,0,0,.34);
}
.oc-style-panel-title { margin-bottom: 6px; color: var(--icon, #718096); font-size: 10px; font-weight: 650; letter-spacing: .5px; text-transform: uppercase; }
.oc-theme-row { display: flex; gap: 6px; margin-bottom: 10px; }
.oc-theme-dot { appearance: none; width: 21px; height: 21px; border: 2px solid transparent; border-radius: 50%; cursor: pointer; }
.oc-theme-dot:hover { transform: scale(1.16); }
.oc-size-row { display: flex; gap: 5px; }
.oc-size-btn {
  flex: 1; padding: 5px; color: var(--main-text-color); background: var(--panel-entry, #fff);
  border: 1px solid var(--panel-border, #d8dde4); border-radius: 6px; cursor: pointer;
}
.oc-size-btn:hover { background: var(--panel-entry-hover, #eef2f7); }

/* Табличное представление и непрерывные tree-guides. */
.oc-table-view {
  flex: 1; min-width: 0; min-height: 0; overflow: hidden;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(circle, var(--grid-dot) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
}
.oc-table-shell { height: 100%; min-height: 0; display: flex; flex-direction: column; gap: 7px; padding: 6px 24px 20px; box-sizing: border-box; }
.oc-table-summary { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.oc-table-summary::-webkit-scrollbar { display: none; }
.oc-table-summary-stat {
  height: 35px; min-width: 112px; box-sizing: border-box; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; color: var(--text-secondary); background: var(--surface-color);
  border: 1px solid var(--border-color); border-radius: 8px; font-size: 12px;
}
.oc-table-summary-stat .material-symbols-outlined { color: #4a9eff; font-size: 16px; }
.oc-table-summary-stat b { color: var(--text-primary); font-size: 13px; }
.oc-table-scroll {
  position: relative; flex: 1; min-height: 0; overflow: auto; background: var(--surface-color);
  border: 1px solid var(--border-color); border-radius: 14px; box-shadow: 0 12px 34px rgba(0,0,0,.11);
  scrollbar-width: none; cursor: grab; touch-action: none;
}
.oc-table-scroll::-webkit-scrollbar { display: none; }
.oc-table-grid { width: 100%; min-width: 1165px; display: grid; }
.oc-structure-table {
  width: 100%; min-width: 1165px; border-collapse: separate; border-spacing: 0;
  table-layout: fixed; color: var(--text-primary); font-size: 12.5px;
}
.oc-col-structure { width: 390px; } .oc-col-person { width: 235px; }
.oc-col-system { width: 260px; } .oc-col-stats { width: 145px; } .oc-col-actions { width: 135px; }
.oc-structure-table th {
  position: sticky; top: 0; z-index: 8; height: 38px; padding: 8px 10px; color: #fff;
  background: linear-gradient(180deg,#294867,#213b56); border-right: 1px solid rgba(255,255,255,.10);
  border-bottom: 1px solid #182f47; font-size: 11px; font-weight: 750; letter-spacing: .035em; text-align: left; text-transform: uppercase;
}
.oc-structure-table th:first-child { left: 0; z-index: 11; border-top-left-radius: 13px; }
.oc-table-row { --oc-row-bg: var(--surface-color); height: 44px; background: var(--oc-row-bg); transition: background .15s, opacity .15s; }
.oc-table-row:hover { --oc-row-bg: color-mix(in srgb,var(--surface-color) 90%,#4a9eff 10%); }
.oc-table-row-root { --oc-row-bg: color-mix(in srgb,var(--surface-color) 92%,var(--text-secondary) 8%) !important; }
.oc-table-row.oc-table-dragging { opacity: .35; }
.oc-structure-table tr[hidden] { display: none !important; }
.oc-structure-table td {
  height: 44px; padding: 5px 10px; background: var(--oc-row-bg);
  border-right: 1px solid color-mix(in srgb,var(--border-color) 74%,transparent);
  border-bottom: 1px solid var(--border-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}
.oc-structure-table td:first-child { position: sticky; left: 0; z-index: 4; background: var(--oc-row-bg); }
.oc-structure-table td.oc-table-hierarchy-cell, .oc-table-actions-cell { overflow: visible; }
.oc-table-entity {
  --oc-level: 0; --oc-guide-color: #aeb6c2; position: relative; isolation: isolate; min-width: 0; height: 34px;
  display: flex; align-items: center; gap: 6px; padding-left: calc(var(--oc-level) * 24px);
}
[data-theme=dark] .oc-table-entity { --oc-guide-color: #626a74; }
.oc-table-hierarchy-guides { position: absolute; z-index: 1; top: -6px; right: 0; bottom: -6px; left: 0; pointer-events: none; }
.oc-table-guide-rail, .oc-table-guide-branch, .oc-table-guide-child-stem {
  position: absolute; left: calc(var(--oc-guide-level) * 24px + 12px); width: 1px; background: var(--oc-guide-color);
}
.oc-table-guide-rail, .oc-table-guide-branch { top: -1px; bottom: -1px; }
.oc-table-guide-branch.is-last { bottom: 50%; }
.oc-table-guide-branch::after { content: ''; position: absolute; top: 50%; left: 0; width: 25px; height: 1px; background: var(--oc-guide-color); }
.oc-table-guide-branch.is-last::after { top: 100%; }
.oc-table-guide-branch.is-leaf::before {
  content: ''; position: absolute; z-index: 1; top: calc(50% - 1.5px); left: 22px;
  width: 5px; height: 5px; box-sizing: border-box; background: var(--oc-row-bg);
  border: 1px solid var(--oc-guide-color); border-radius: 50%;
}
.oc-table-guide-branch.is-last.is-leaf::before { top: calc(100% - 1.5px); }
.oc-table-guide-child-stem { top: 50%; bottom: -1px; }
.oc-table-expander {
  position: relative; z-index: 3; width: 24px; height: 24px; flex: 0 0 24px; display: inline-flex;
  align-items: center; justify-content: center; padding: 0; color: var(--text-secondary);
  background: var(--oc-row-bg); border: 0; border-radius: 7px; cursor: pointer;
}
.oc-table-expander.is-empty { opacity: 0; pointer-events: none; }
.oc-table-expander .material-symbols-outlined { font-size: 20px; transform: rotate(0); transition: transform .4s cubic-bezier(.16,1,.3,1); }
.oc-table-expander.is-expanded .material-symbols-outlined { transform: rotate(90deg); }
.oc-table-entity-icon { position: relative; z-index: 2; flex: 0 0 auto; color: #4a9eff; font-size: 18px; }
.oc-table-entity-root .oc-table-entity-icon { color: var(--text-secondary); }
.oc-table-entity-copy { position: relative; z-index: 2; min-width: 0; flex: 1; overflow: hidden; display: flex; flex-direction: column; gap: 1px; }
.oc-table-entity-name, .oc-table-entity-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-table-entity-name { font-weight: 650; line-height: 1.12; }
.oc-table-entity-meta { color: var(--text-secondary); font-size: 10px; }
.oc-table-entity-root .oc-table-entity-copy, .oc-table-entity-dept .oc-table-entity-copy { flex-direction: row; align-items: center; gap: 10px; }
.oc-table-entity-root .oc-table-entity-name, .oc-table-entity-dept .oc-table-entity-name { max-width: 52%; font-size: 12.5px; }
.oc-table-manager-role { min-height: 25px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px 4px 6px; background: color-mix(in srgb,var(--surface-color) 88%,var(--text-secondary) 12%); border-radius: 7px; }
.oc-table-manager-role-icon { font-size: 16px; }
.oc-table-person { min-width: 0; display: flex; align-items: center; gap: 9px; }
.oc-table-person-empty { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-secondary); background: var(--border-color); border-radius: 50%; }
.oc-table-person-empty .material-symbols-outlined { font-size: 17px; }
.oc-table-person-meta { min-width: 0; }
.oc-table-person-name, .oc-table-person-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-table-person-name { font-weight: 650; }
.oc-table-person-email { margin-top: 2px; color: var(--text-secondary); font-size: 10.5px; }
.oc-table-position-cell { white-space: normal !important; }
.oc-table-position-text {
  display: -webkit-box; max-height: 29px; overflow: hidden; color: var(--text-primary);
  font-size: 12px; line-height: 14.5px; white-space: normal; overflow-wrap: anywhere;
  -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.oc-table-stats-cell { color: var(--text-secondary); }
.oc-table-actions-cell { padding-right: 6px !important; padding-left: 6px !important; }
.oc-table-actions { display: flex; align-items: center; gap: 2px; }
.oc-table-action {
  appearance: none; width: 23px; height: 24px; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; color: var(--text-secondary); background: color-mix(in srgb,var(--surface-color) 86%,#94a3b8 14%);
  border: 1px solid var(--border-color); border-radius: 7px; cursor: pointer;
}
.oc-table-action:hover { color: #4a9eff; border-color: #4a9eff; background: rgba(74,158,255,.12); transform: translateY(-1px); }
.oc-table-action.success { color: #22c55e; } .oc-table-action.danger { color: #ef4444; }
.oc-table-action.detail { color: #7b8491; }
.oc-table-action .material-symbols-outlined { font-size: 15px; }
.oc-table-row.oc-table-drop-before td { box-shadow: inset 0 3px 0 #4a9eff; }
.oc-table-row.oc-table-drop-after td { box-shadow: inset 0 -3px 0 #4a9eff; }
.oc-table-row.oc-table-drop-inside td { background: color-mix(in srgb,var(--surface-color) 72%,#4a9eff 28%); }
.oc-table-row.oc-table-drop-head td { background: color-mix(in srgb,var(--surface-color) 70%,#3b82f6 30%); }
.oc-table-row.oc-table-drop-member td { background: color-mix(in srgb,var(--surface-color) 72%,#22c55e 28%); }
.oc-table-row.oc-table-drop-department td { background: color-mix(in srgb,var(--surface-color) 74%,#7c6fca 26%); }
.oc-table-row.oc-table-drop-head .oc-table-hierarchy-cell::after,
.oc-table-row.oc-table-drop-member .oc-table-hierarchy-cell::after,
.oc-table-row.oc-table-drop-inside .oc-table-hierarchy-cell::after {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%); padding: 4px 7px;
  color: #fff; border-radius: 7px; font-size: 9px; font-weight: 750; pointer-events: none;
}
.oc-table-row.oc-table-drop-department .oc-table-hierarchy-cell::after {
  content: 'ПОД СОТРУДНИКА'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  padding: 4px 7px; color: #fff; background: #6d5fc0; border-radius: 7px;
  font-size: 9px; font-weight: 750; pointer-events: none;
}
.oc-table-row.oc-table-drop-head .oc-table-hierarchy-cell::after { content: 'РУКОВОДИТЕЛЬ'; background: #2563eb; }
.oc-table-row.oc-table-drop-member .oc-table-hierarchy-cell::after { content: 'В ПОДРАЗДЕЛЕНИЕ'; background: #16a34a; }
.oc-table-row.oc-table-drop-inside .oc-table-hierarchy-cell::after { content: 'ВНУТРЬ'; background: #2563eb; }

[data-theme=light] .org-structure-screen {
  --surface-color: #fff; --bg-color: #f2f4f7; --border-color: #d4d9e0;
  --text-primary: #1f2937; --text-secondary: #687386;
}

@media (max-width: 1100px) {
  .org-screen-title { min-width: auto; }
  .org-screen-title strong, .oc-tool-primary span:last-child { display: none; }
  .oc-search { width: 300px; }
}
@media (max-width: 900px) {
  #btn-org-structure-group { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .oc-card, .oc-emp-panel, .oc-emp-item, .oc-editor-drawer,
  .oc-table-expander .material-symbols-outlined { animation: none !important; transition: none !important; }
}
