/* ==========================================================================
   sp12fc-shell.css — оболочка «настольной программы» (SP12Calc)
   для боевой страницы pzh-risk.ru/sp12.html.

   Оболочка = заголовок окна, меню, панель инструментов, строка состояния
   + плотная «офисная» тема для дерева, рабочей области и предпросмотра.

   Расчётная логика не затрагивается: все кнопки оболочки вызывают те же
   обработчики data-act, что и штатные элементы калькулятора.
   ========================================================================== */

/* ------------------------------- переменные ------------------------------ */
.fcx-shell {
  --fcx-win:      #eef1f6;
  --fcx-panel:    #ffffff;
  --fcx-panel-2:  #f6f8fb;
  --fcx-edge:     #c8ccd4;
  --fcx-edge-soft:#dfe3ea;
  --fcx-text:     #1c1c1c;
  --fcx-muted:    #6a7078;
  --fcx-accent:   #0a5cbd;
  --fcx-sel:      #316ac5;
  --fcx-ui-font:  "Segoe UI", Tahoma, "MS Sans Serif", Arial, sans-serif;

  position: relative;
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  background: var(--fcx-win);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--fcx-ui-font);
  color: var(--fcx-text);
}

/* ------------------------------ заголовок окна --------------------------- */
.fcx-titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 4px 0 8px;
  background: linear-gradient(180deg, #ffffff 0%, #eef1f6 100%);
  border-bottom: 1px solid var(--fcx-edge);
  border-radius: 3px 3px 0 0;
}
.fcx-titlebar__ico { width: 16px; height: 16px; flex: 0 0 auto; }
.fcx-titlebar__txt {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--fcx-text);
}
.fcx-titlebar__path { color: var(--fcx-muted); }
.fcx-titlebar__btns { display: flex; gap: 2px; }
.fcx-tbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 22px;
  padding: 0;
  line-height: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fcx-text);
  font: 15px/1 var(--fcx-ui-font);
  cursor: pointer;
  border-radius: 2px;
}
.fcx-tbtn:hover { background: #dfe6f2; }
.dark-theme .fcx-tbtn { color: #e2e8f0; }
.dark-theme .fcx-tbtn:hover { background: rgba(255, 255, 255, .12); }
.fcx-tbtn svg { width: 12px; height: 12px; display: block; color: currentColor; }

/* --------------------------------- меню ---------------------------------- */
.fcx-menubar {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 24px;
  padding: 0 2px;
  background: var(--fcx-win);
  border-bottom: 1px solid var(--fcx-edge-soft);
  overflow-x: auto;
  scrollbar-width: thin;
}
.fcx-menu { position: relative; flex: 0 0 auto; }
.fcx-menu__btn {
  border: 0;
  background: transparent;
  padding: 3px 9px;
  font: 12px/1.3 var(--fcx-ui-font);
  color: var(--fcx-text);
  cursor: pointer;
  white-space: nowrap;
}
.fcx-menu__btn:hover,
.fcx-menu.is-open .fcx-menu__btn { background: #cfe0f7; }
.fcx-menu__list {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 60;
  min-width: 230px;
  margin: 0;
  padding: 2px;
  list-style: none;
  background: var(--fcx-panel);
  border: 1px solid var(--fcx-edge);
  box-shadow: 2px 2px 6px rgba(20, 30, 50, .22);
}
.fcx-menu__list[hidden] { display: none; }
.fcx-menu__item {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 4px 12px 4px 20px;
  text-align: left;
  font: 12px/1.35 var(--fcx-ui-font);
  color: var(--fcx-text);
  cursor: pointer;
  white-space: nowrap;
}
.fcx-menu__item:hover { background: var(--fcx-accent); color: #fff; }
.fcx-menu__item[disabled] { color: #a6abb3; cursor: default; }
.fcx-menu__item[disabled]:hover { background: transparent; color: #a6abb3; }
.fcx-menu__sep { height: 1px; margin: 3px 2px; background: var(--fcx-edge-soft); }

/* --------------------------- панель инструментов ------------------------- */
.fcx-toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  min-height: 32px;
  padding: 3px 4px;
  background: linear-gradient(180deg, #f7f9fc 0%, #e9edf4 100%);
  border-bottom: 1px solid var(--fcx-edge);
  overflow-x: auto;
  scrollbar-width: thin;
}
.fcx-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 26px; height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
}
.fcx-tool:hover { border-color: #9db8dd; background: #dce8fa; }
.fcx-tool:active { background: #c3d7f2; }
.fcx-tool svg { width: 16px; height: 16px; display: block; }
.fcx-tool--danger:hover { border-color: #d99; background: #f6dede; }
.fcx-sep {
  width: 1px; height: 20px;
  margin: 0 4px;
  background: #b9bfc9;
  flex: 0 0 auto;
}
.fcx-grip {
  width: 6px; height: 20px;
  margin-right: 4px;
  background-image: radial-gradient(circle, #a8b0bb 1px, transparent 1px);
  background-size: 3px 3px;
  flex: 0 0 auto;
}

/* --------------------------- рабочая область ------------------------------ */
.fcx-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--fcx-win);
}

/* --- плотная тема для штатных панелей калькулятора --- */
.fcx-shell .sa-app,
.fcx-shell .sa-toolbar,
.fcx-shell .sa-panel,
.fcx-shell .sa-main {
  font-family: var(--fcx-ui-font);
}
.fcx-shell .sa-toolbar {
  padding: 4px 6px;
  background: var(--fcx-panel-2);
  border-bottom: 1px solid var(--fcx-edge-soft);
}
.fcx-shell .sa-toolbar .sa-btn {
  border-radius: 0;
  border: 1px solid var(--fcx-edge);
  background: #e4e8ef;
  color: #333a44;
  font-size: 12px;
  padding: 3px 10px;
}
.fcx-shell .sa-toolbar .sa-btn:hover { background: #d3dceb; }
.fcx-shell .sa-toolbar .sa-btn--primary,
.fcx-shell .sa-toolbar .sa-btn.is-active {
  background: var(--fcx-panel);
  color: var(--fcx-accent);
  font-weight: 700;
  border-color: var(--fcx-accent);
}
.fcx-shell .sa-toolbar__status {
  font-size: 11px;
  color: var(--fcx-muted);
}

/* старое широкоеtoolbar с эмодзи скрываем — его команды живут в оболочке */
.fcx-shell .sp12-tb { display: none; }
.fcx-shell .sp12-cmd-ctx {
  background: var(--fcx-panel-2);
  border-bottom: 1px solid var(--fcx-edge-soft);
  padding: 3px 6px;
}

/* дерево объектов */
.fcx-shell .project-container {
  align-items: stretch;
  gap: 10px;
  padding: 8px;
}
.fcx-shell .project-tree-panel {
  background: var(--fcx-panel);
  border: 1px solid var(--fcx-edge);
  border-radius: 2px;
  overflow: hidden;
}
.fcx-shell .project-tree-panel__title {
  background: var(--fcx-win);
  border-bottom: 1px solid var(--fcx-edge);
  font-size: 11px;
  color: var(--fcx-muted);
  letter-spacing: .02em;
}
.fcx-shell .sp12-tree {
  font-size: 12px;
  background: var(--fcx-panel);
}
.fcx-shell .sp12-tree__node { min-height: 20px; }
.fcx-shell .sp12-tree__label { font-size: 12px; }
.fcx-shell .tree-node {
  border-radius: 0;
  font-size: 12px;
}
.fcx-shell .tree-node:hover { background: #e8eef9; }
.fcx-shell .tree-node-active,
.fcx-shell .tree-node.is-active {
  background: var(--fcx-sel);
  color: #fff;
}
.fcx-shell .tree-node-active .tree-node__label,
.fcx-shell .tree-node.is-active .tree-node__label { color: #fff; }
.fcx-shell .sp12-tree-tools {
  background: var(--fcx-win);
  border-bottom: 1px solid var(--fcx-edge-soft);
  padding: 3px 4px;
}
.fcx-shell .sp12-tree-search,
.fcx-shell .sa-input {
  border-radius: 0;
  font-size: 12px;
}

/* рабочая область / инспектор */
.fcx-shell .project-workspace-panel {
  background: var(--fcx-panel);
  border: 1px solid var(--fcx-edge);
  border-radius: 2px;
  padding: 8px;
}
.fcx-shell .workspace-section {
  background: var(--fcx-panel);
  border: 1px solid var(--fcx-edge-soft);
  border-radius: 0;
  padding: 10px 12px;
  font-size: 12px;
}
.fcx-shell .sa-h3 {
  font-size: 13px;
  color: #2a3340;
  border-bottom: 1px solid var(--fcx-edge-soft);
  padding-bottom: 3px;
}
.fcx-shell .sa-main {
  background: var(--fcx-panel);
  border: 1px solid var(--fcx-edge);
  border-radius: 2px;
  padding: 10px 12px;
  font-size: 12px;
}
.fcx-shell .sa-panel__title,
.fcx-shell .sa-panel h3 { font-size: 13px; }

/* ----------------------------- строка состояния --------------------------- */
.fcx-status {
  display: flex;
  gap: 1px;
  flex: 0 0 auto;
  background: var(--fcx-edge);
  border-top: 1px solid var(--fcx-edge);
  border-radius: 0 0 3px 3px;
}
.fcx-status__cell {
  padding: 2px 8px;
  background: var(--fcx-win);
  color: #333a44;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
}
.fcx-status__cell--wide { flex: 1 1 auto; min-width: 0; }
.fcx-status__cell:last-child { flex: 0 0 auto; }

/* ------------------------- диалог «О программе» -------------------------- */
.fcx-about {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 25, 40, .45);
}
.fcx-about[hidden] { display: none; }
.fcx-about__win {
  width: min(420px, 92vw);
  background: var(--fcx-panel);
  border: 1px solid var(--fcx-edge);
  box-shadow: 0 12px 40px rgba(10, 20, 35, .35);
  font-size: 12px;
}
.fcx-about__head {
  padding: 4px 8px;
  background: linear-gradient(180deg, #ffffff 0%, #eef1f6 100%);
  border-bottom: 1px solid var(--fcx-edge);
  font-weight: 600;
}
.fcx-about__body { padding: 12px 14px; line-height: 1.6; }
.fcx-about__body b { color: var(--fcx-accent); }
.fcx-about__foot {
  padding: 8px 12px;
  border-top: 1px solid var(--fcx-edge);
  text-align: right;
}

/* --------------------------------- мобильный ----------------------------- */
@media (max-width: 900px) {
  .fcx-shell { margin: 8px 0 12px; }
  .fcx-titlebar__path { display: none; }
  .fcx-menubar { overflow-x: visible; }
  .fcx-toolbar { overflow-x: auto; }
  .fcx-shell .project-container { padding: 6px; }
  .fcx-status__cell--wide { display: none; }
  .fcx-status__cell { font-size: 10px; padding: 2px 5px; }
}
@media (max-width: 480px) {
  .fcx-tbtn { width: 26px; height: 20px; }
  .fcx-titlebar__txt { font-size: 11px; }
}

/* ------------------------------ печать ----------------------------------- */
@media print {
  .fcx-titlebar, .fcx-menubar, .fcx-toolbar, .fcx-status { display: none !important; }
  .fcx-shell { border: 0; box-shadow: none; margin: 0; }
}

/* --------------------------- тёмная тема --------------------------------- */
.dark-theme .fcx-shell {
  --fcx-win:      #1b2430;
  --fcx-panel:    #22303f;
  --fcx-panel-2:  #1c2733;
  --fcx-edge:     #3a4a5c;
  --fcx-edge-soft:#2c3a49;
  --fcx-text:     #e6ecf3;
  --fcx-muted:    #9fb0c2;
  --fcx-accent:   #5b9bf0;
  background: var(--fcx-win);
  border-color: #3a4a5c;
  color: var(--fcx-text);
}
.dark-theme .fcx-titlebar {
  background: linear-gradient(180deg, #26333f 0%, #1b2430 100%);
}
.dark-theme .fcx-menubar { background: var(--fcx-win); }
.dark-theme .fcx-menu__list { background: var(--fcx-panel); }
.dark-theme .fcx-menu__item { color: var(--fcx-text); }
.dark-theme .fcx-toolbar {
  background: linear-gradient(180deg, #24313e 0%, #1b2430 100%);
}
.dark-theme .fcx-status { background: #3a4a5c; }
.dark-theme .fcx-status__cell { background: var(--fcx-win); color: var(--fcx-text); }
.dark-theme .fcx-shell .sa-toolbar .sa-btn {
  background: #2b3948; color: var(--fcx-text); border-color: var(--fcx-edge);
}
.dark-theme .fcx-shell .sa-toolbar .sa-btn--primary,
.dark-theme .fcx-shell .sa-toolbar .sa-btn.is-active {
  background: var(--fcx-panel); color: var(--fcx-accent); border-color: var(--fcx-accent);
}
.dark-theme .fcx-shell .tree-node-active,
.dark-theme .fcx-shell .tree-node.is-active { background: var(--fcx-sel); color: #fff; }
.dark-theme .fcx-about__win { background: var(--fcx-panel); color: var(--fcx-text); }
.dark-theme .fcx-about__head {
  background: linear-gradient(180deg, #26333f 0%, #1b2430 100%);
}


/* ---- сброс «мобильных» размеров кнопок сайта внутри оболочки ---- */
.fcx-shell .fcx-menubar {
  height: auto;
  min-height: 26px;
  align-items: center;
  overflow: visible !important;   /* выпадающие списки меню не должны обрезаться */
  position: relative;
  z-index: 40;
}
.fcx-shell .fcx-menu__btn {
  min-height: 0;
  height: 24px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.fcx-shell .fcx-tool {
  min-height: 26px;
  width: 28px;
  height: 26px;
  padding: 0;
}
.fcx-shell .fcx-tbtn { min-height: 0; height: 22px; }
.fcx-shell .fcx-status__cell { min-height: 0; }

/* --------------------------- состояния оболочки ------------------------- */
.fcx-shell.fcx-tree-hidden .project-tree-panel { display: none; }
.fcx-shell.fcx-tree-hidden .project-container { grid-template-columns: minmax(0, 1fr); }
.fcx-shell.fcx-font-large { font-size: 14px; }
.fcx-shell.fcx-font-small { font-size: 11px; }
.fcx-shell.fcx-font-large .fcx-toolbar,
.fcx-shell.fcx-font-large .fcx-status__cell,
.fcx-shell.fcx-font-large .fcx-menubar { font-size: 13px; }
.fcx-shell.fcx-font-small .fcx-toolbar,
.fcx-shell.fcx-font-small .fcx-status__cell,
.fcx-shell.fcx-font-small .fcx-menubar { font-size: 11px; }

/* --- сворачивание панели результатов ------------------------------------ */
.fcx-restore {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px dashed var(--tz-e2e8f0-border);
  border-radius: var(--r-md);
  background: var(--tz-f8fafc-card);
  color: var(--tz-334155-text);
  font-size: 13px;
}
html.dark-theme .fcx-restore {
  background: #101a2e;
  border-color: #2b3a5c;
  color: #cbd5e1;
}
.fcx-shell.fcx-results-collapsed .fcx-restore { display: flex; }
.fcx-shell.fcx-results-collapsed .project-workspace-panel { display: none; }
.fcx-shell.fcx-results-collapsed .project-container { grid-template-columns: minmax(0, 1fr); }
.fcx-shell.fcx-results-collapsed .fcx-tbtn#fcx-collapse { opacity: .45; }
@media (max-width: 900px) {
  .fcx-shell.fcx-results-collapsed .project-container { grid-template-columns: minmax(0, 1fr); }
}

/* -------------------- правая часть меню: статус и кнопки ------------------- */
.fcx-menubar { justify-content: flex-start; }
.fcx-menubar__right {
  order: 2;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  font-size: 12px;
  color: var(--fcx-muted);
  white-space: nowrap;
}
.fcx-menubar__btns { display: flex; gap: 2px; }
.fcx-menubar__right .fcx-tbtn { width: 26px; height: 22px; }

@media (max-width: 768px) {
  .fcx-menubar__state { display: none; }
  .fcx-menubar__right { padding-left: 6px; }
}
