:root {
  --bg: #ffffff;
  --panel: #f3f5f9;
  --text: #0d4b96;
  --muted: #606060;
  --btn-bg: #eff3f8;
  --btn-txt: #11376e;
  --border: #0d4b96;
  --tab-sel: #dbe8fa;
  --tab-bg: #f6f6f6;
  --field: #ffffff;
  --primary-bg: #0d4b96;
  --primary-txt: #ffffff;
  --header-bg: var(--bg);
  --tab-txt: #0d4b96;
  --menu-bg: #eff3f8;
  --menu-txt: #0d4b96;
  --zone-bg: #f0f4fa;
  --zone-txt: #0d4b96;
  --chart-bg: #ffffff;
  --scrollbar: color-mix(in srgb, var(--border) 55%, transparent);
}
* { box-sizing: border-box; }
/* узкие скроллбары по всему проекту */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--border) 80%, transparent); }
body { margin: 0; font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }

/* ---------- логин ---------- */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--panel); background-size: cover; background-position: center; }
.login-card { background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(5px); border: 1px solid var(--border); border-radius: 10px; padding: 32px; width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0; font-size: 22px; text-align: center; }
.login-sub { text-align: center; color: var(--muted); margin: 0 0 8px; }
input, select, textarea { padding: 4px 7px; border: 1px solid var(--border); border-radius: 5px; background: var(--field); color: var(--text); font-size: 13px; }
button { padding: 3.5px 10px; border: 1px solid var(--border); border-radius: 5px; background: var(--btn-bg); color: var(--btn-txt); cursor: pointer; font-size: 13px; }
button:hover { filter: brightness(0.97); }
button.primary { background: var(--primary-bg); color: var(--primary-txt); }
button.linklike { background: none; border: none; color: var(--muted); text-decoration: underline; }
.error { color: #c00; min-height: 18px; }

/* ---------- приложение ---------- */
.app { display: flex; flex-direction: column; height: 100vh; position: relative; }

/* ---------- Экраны: всё пространство рабочего окна, фото-фон, римский номер ---------- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column;
  background-size: cover; background-position: center; background-color: var(--bg); }
.screen-num { position: absolute; top: 10px; right: 14px; z-index: 95;
  border: none; border-radius: 6px; background: rgba(255,255,255,.45);
  font-size: 26px; font-weight: 700; line-height: 1.15; padding: 2px 10px;
  color: color-mix(in srgb, var(--header-bg) 65%, #000 35%); cursor: pointer; }
.screen-num:hover { background: rgba(255,255,255,.7); }
#screen-num-0 { font-size: 16px; }

/* Главный экран: верхняя половина — 2 части, нижняя — 4 части */
.home-grid { position: absolute; inset: 0; display: grid;
  grid-template-columns: repeat(4, 1fr); grid-template-rows: 1fr 1fr;
  gap: 8px; padding: 8px; }
.home-part { position: relative; min-height: 0; border-radius: 8px;
  border: 1px dashed var(--border);
  background: color-mix(in srgb, var(--zone-bg) 55%, transparent); }
.home-part:nth-child(1), .home-part:nth-child(2) { grid-column: span 2; }
.home-num { position: absolute; top: 6px; right: 10px; font-size: 13px;
  color: var(--muted); }
/* ч.2 — под кнопкой «Главная», чтобы не пересекались */
.home-part:nth-child(2) .home-num { top: 46px; }

/* кнопки Главного экрана: 1–2 — 8×5 см, 3–6 — 5×4 см */
.home-btn { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 5cm; height: 4cm; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--btn-bg); color: var(--btn-txt);
  font-weight: 700; font-size: 14px; line-height: 1.25; text-align: center;
  padding: 6px 8px; word-wrap: break-word; }
.home-btn.big { width: 8cm; height: 5cm; font-size: 19px; }
.home-btn:hover { filter: brightness(1.12); }
.screen-menu { position: absolute; top: 50px; right: 14px; z-index: 96;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,.3); padding: 6px;
  display: flex; flex-direction: column; gap: 3px; min-width: 170px; }
.screen-menu button { border: none; background: none; text-align: left;
  padding: 7px 10px; border-radius: 5px; color: var(--text); font-size: 13px; }
.screen-menu button:hover { background: var(--tab-sel); }
.screen-menu button.current { font-weight: 700; }

.app-header { flex: none; height: 3cm; background: var(--header-bg);
  display: flex; align-items: center; padding: 0 16px; }
.header-logo-box { flex: none; width: 5cm; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; margin-right: 16px; cursor: pointer; }
.header-logo { max-width: 4.6cm; max-height: 2.2cm; object-fit: contain; }
.screen-title { flex: 1; text-align: center; font-size: 20px; font-weight: 700;
  color: var(--text); padding: 0 12px; }
.greeting { margin: 0; font-size: 10pt; font-weight: normal; color: var(--text);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-main { flex: 1; display: flex; min-height: 0; }
.sidebar { width: max-content; min-width: 200px; background: var(--panel); display: flex; flex-direction: column; align-items: stretch; padding: 14px 10px; gap: 10px; position: relative; z-index: 50; }
.tab { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 8px; text-align: left; color: var(--menu-txt); background: var(--menu-bg); border: none; }
/* объёмные кнопки меню панели (верхний уровень дерева):
   на всю ширину панели, панель сама расширяется по самому длинному названию */
.tab:not(.sub) {
  width: 100%;
  height: 38px;
  margin: 0;
  gap: 6px;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--menu-bg), white 20%),
    var(--menu-bg) 45%,
    color-mix(in srgb, var(--menu-bg), black 12%));
  box-shadow: 0 2px 3px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.1);
}
.tab:not(.sub):hover { filter: brightness(1.05); }
.tab:not(.sub):active { transform: translateY(1px); box-shadow: 0 1px 1px rgba(0,0,0,.18), inset 0 1px 2px rgba(0,0,0,.18); }
.tab.active { font-weight: 600; }
.tab:not(.sub).active {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--tab-sel), black 10%),
    var(--tab-sel) 55%,
    color-mix(in srgb, var(--tab-sel), white 6%));
  box-shadow: inset 0 2px 4px rgba(0,0,0,.25), inset 0 -1px 0 rgba(255,255,255,.25);
}
/* древовидное меню: подкнопки «Панели управления» */
.menu-group { position: relative; display: flex; flex-direction: column; gap: 6px; }
/* ряд: знак +/− ОТДЕЛЬНО слева от кнопки с подменю;
   при длинных названиях панель расширяется сама */
.menu-group-head { display: flex; align-items: center; gap: 6px; }
.menu-group-head .tab-parent { flex: 1 1 auto; min-width: 0; }
.grp-toggle { flex: none; width: 18px; height: 18px; padding: 0;
  border: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
  background: var(--menu-bg); color: var(--menu-txt);
  font-size: 12px; line-height: 16px; text-align: center;
  cursor: pointer; border-radius: 5px; }
.grp-toggle:hover { filter: brightness(1.1); }
.sidebar.collapsed .grp-toggle { display: none; }
.menu-sub { position: relative; display: flex; flex-direction: column; gap: 6px; width: 100%; margin: 0; padding-left: 22px; }
/* вертикальная линия-ствол дерева: от родителя до середины последней подкнопки */
.menu-sub::before {
  content: ''; position: absolute; left: 10px; top: -5px; bottom: 17px; width: 2px;
  background: var(--menu-txt); opacity: .35; border-radius: 1px;
}
.tab.sub { position: relative; width: 100%; height: 34px; margin: 0; padding: 8px 10px 8px 14px; font-size: 13px; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
/* горизонтальный отвод от ствола к каждой подкнопке */
.tab.sub::before {
  content: ''; position: absolute; left: -12px; top: 50%; width: 12px;
  border-top: 2px solid var(--menu-txt); opacity: .35;
}
.tab.sub:hover { filter: brightness(1.05); }
.tab.sub.active { background: var(--tab-sel); box-shadow: inset 0 1px 3px rgba(0,0,0,.2); }
.sidebar-bottom { margin-top: auto; margin-bottom: 26px; font-size: 13px; color: var(--muted); }
.sidebar-toggle { position: absolute; bottom: 14px; right: 8px; width: 15px; height: 15px; padding: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.sidebar-toggle .tri { width: 0; height: 0; border-top: 3px solid transparent; border-bottom: 3px solid transparent; border-left: 5px solid var(--text); }
.sidebar.collapsed .sidebar-toggle .tri { border-left: none; border-right: 5px solid var(--text); }
.sidebar.collapsed .sidebar-toggle { right: 19px; }
.sidebar.collapsed { width: 54px; min-width: 54px; padding: 14px 8px; }
.sidebar.collapsed .tab span:not(.ico),
.sidebar.collapsed .sidebar-bottom { display: none; }
.sidebar.collapsed .menu-sub { display: none; }
/* свёрнутая панель: подменю выпадает справа от кнопки «Панель управления» */
.sidebar.collapsed .menu-group:hover .menu-sub,
.sidebar.collapsed .menu-group:focus-within .menu-sub {
  display: flex;
  position: absolute;
  left: calc(100% - 6px);
  top: 0;
  width: 150px;
  padding: 8px 10px;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  z-index: 60;
}
.sidebar.collapsed .menu-sub::before,
.sidebar.collapsed .tab.sub::before { display: none; }
.sidebar.collapsed .menu-sub .tab { justify-content: flex-start; }
.sidebar.collapsed .menu-sub .tab.sub { width: 100%; }
.sidebar.collapsed .menu-sub .tab span:not(.ico) { display: inline; }
.sidebar.collapsed .tab { justify-content: center; }

.history { display: flex; flex-direction: column; gap: 10px; }
.hist-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--tab-bg); color: var(--tab-txt); }
.hist-top { display: flex; gap: 10px; align-items: baseline; }
.hist-chips { display: flex; gap: 4px; margin: 8px 0; flex-wrap: wrap; }
.chip-mini { display: inline-block; width: 20px; height: 20px; border-radius: 4px; border: 1px solid var(--border); }
.hist-del { font-size: 12px; }
.hist-actions { display: flex; gap: 8px; }
.hist-apply { font-size: 12px; }
.content { flex: 1; padding: 14px 18px; overflow: auto; position: relative;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(3px); }
.content h2 { margin: 0 0 8px; font-size: 18px; }
.page { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.top { align-items: flex-start; }
.box { border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; background: var(--tab-bg); color: var(--tab-txt); }
.box.small { font-size: 12px; color: var(--tab-txt); max-height: 150px; overflow: auto; }
.muted { color: var(--muted); font-size: 12.5px; }

/* компактные заголовки в Цвет и Настройках */
#page-color h3, #page-settings h3 { margin: 8px 0 4px; font-size: 14.5px; }
#page-settings h4 { margin: 6px 0 4px; font-size: 13.5px; }

.preview { max-width: 140px; max-height: 140px; border: 1px solid var(--border); border-radius: 6px; }
.logo-preview { width: 100px; height: 64px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: var(--tab-bg); }
/* Настройки: две зоны по половине ширины Области, сервисы разделены короткой чертой */
.settings-zones { display: flex; gap: 20px; align-items: stretch; }
.settings-zone { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--zone-bg); color: var(--zone-txt); }
.settings-zone .row { flex-wrap: wrap; }
.settings-zone select { max-width: 100%; }
/* Зона 1 компактнее: меньше отступы и промежутки */
.settings-zones .settings-zone:first-child { gap: 6px; padding: 10px 12px; }
.settings-zones .settings-zone:first-child .row { gap: 6px; }
.settings-zones .settings-zone:first-child .short-divider { margin: 4px 0 3px; }
.favicon-preview { width: 20px; height: 20px; object-fit: contain; border: 1px solid var(--border); border-radius: 4px; background: var(--tab-bg); }
.short-divider { width: 7cm; max-width: 85%; border: none; border-top: 1px solid var(--border); opacity: .45; margin: 8px 0 6px; }
/* таблица пользователей: ширина столбцов — по содержимому */
#users-table { width: 100%; max-width: calc(100% - 4px); border-collapse: collapse; }
#users-table th, #users-table td { font-size: 12px; padding: 3px 6px; border: 1px solid var(--border); }
#users-table .u-date { white-space: nowrap; }
#users-table td select { width: 100%; max-width: 100%; font-size: 12px; }
/* кнопки действий: в строку при достаточной ширине, при нехватке — переносятся */
#users-table td:last-child { white-space: normal; }
#users-table td:last-child button { white-space: nowrap; margin: 2px 6px 2px 0; font-size: 12px; padding: 2px 8px; }
.u-logo-select { max-width: 150px; padding: 2px 4px; font-size: 12.5px; }
.palette { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 70px; text-align: center; }
.swatch .chip { height: 22px; border: 1px solid var(--border); border-radius: 4px; }
.swatch .rgb { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* --- вкладка Цвет: три зоны (высоты на 20% больше прежних областей) --- */
.color-zones { display: flex; gap: 12px; align-items: stretch; }
.color-zone { position: relative; flex: 1 1 0; min-width: 0; min-height: 810px;
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  background: var(--zone-bg); color: var(--zone-txt); }
.color-zone.future { border-style: dashed; }
.color-zone h3 { margin: 0; }
.color-zone h3:not(.zone-head h3) { font-size: 14px; }
.color-zone label { font-size: 13px; }
.color-zone .row { flex-wrap: wrap; }
.color-zone .row.top { align-items: flex-start; }
.color-zone .zone-head { gap: 10px; }
.future-box { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 12.5px; }
/* переключатель Простые/Тонкие */
.mode-lbl { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }
.mode-lbl input { margin: 0; }
.color-block { display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px;
  background: var(--tab-bg); color: var(--tab-txt); }
.color-block.off { opacity: .45; pointer-events: none; }
.color-block h3 { margin: 0 0 2px; font-size: 14px; }
.color-zone .save-row { margin-top: auto; }
/* радио-кнопки и галочки привязаны к цвету «Кнопки» темы */
input[type=radio], input[type=checkbox] { accent-color: var(--btn-bg); }
.chart-bg-choice { display: inline-flex; gap: 10px; font-size: 12px; }
.chart-bg-choice label { display: inline-flex; align-items: center; gap: 3px; cursor: pointer; }
.chart-bg-choice input { margin: 0; }
.elem-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.elem-row input[type=color] { width: 42px; height: 19px; padding: 0; border: 1px solid var(--border); border-radius: 3px; background: var(--field); cursor: pointer; }

/* --- область Звук: Зона 1 (1/3) — распознавание, Зона 2 (2/3) — озвучивание --- */
.sound-zones { display: flex; gap: 12px; align-items: stretch; }
.sound-zones .sources-zone:first-child { flex: 0 1 33.3%; min-width: 0; }
.sound-zones .sources-zone:last-child { flex: 1 1 0; min-width: 0; }

/* --- вкладка Звук: секции --- */
.section-divider { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.rec-time { width: 72px; }
.rec-time-label { font-size: 13px; color: var(--muted); margin: 0; }
#rec-timer { font-variant-numeric: tabular-nums; min-width: 48px; }

/* --- область Регионы: две зоны рядом, каждая половина ширины --- */
.regions-zones { display: flex; gap: 12px; align-items: stretch; }
.regions-zones + .regions-zones { margin-top: 12px; } /* ряды зон — друг под другом */
.regions-zones .sources-zone { flex: 1 1 0; min-width: 0; }
/* сервис добавления внешних источников — под таблицей, по центру низа зоны */
.ext-add { display: flex; flex-direction: column; align-items: center;
  margin-top: auto; font-size: 11px; }
.ext-add .row { gap: 8px; }
.ext-add select { font-size: 11px; }
.ext-add button { font-size: 11px; padding: 2px 8px; }
/* Зона 1: содержимое ближе к верхней границе */
#page-regions .sources-zone.tight { padding-top: 4px; }
#page-regions .sources-zone.tight .zone-head { margin-bottom: -10px; min-height: 0; }
/* Зоны 2 и 3 ниже на 20% */
#page-regions .regions-zones:nth-child(2) .src-drop { max-height: 291px; }
#page-regions .regions-zones:nth-child(2) #macro-map { min-height: 240px; }
/* Зона 1 выше на 30%: скроллы подняты до 364px */
.regions-zones .sources-zone:first-child .src-drop { max-height: 364px; }
/* скролл «Объединение» шире на 30% за счёт «Стран» */
#page-regions .src-cols .src-colbox:first-child { flex: 1.3 1 0; }
#src-macro .src-item { cursor: pointer; }
.src-search { width: 100%; box-sizing: border-box; font-size: 12.5px;
  padding: 3px 8px; margin-bottom: 4px; }
/* таблица внешних источников (Зона 1) */
#ext-src-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
#ext-src-table th, #ext-src-table td { padding: 3px 6px; border: 1px solid var(--border); text-align: left; }
#ext-src-table td:last-child { text-align: right; white-space: nowrap; }
#ext-src-table button { padding: 1.5px 8px; font-size: 11.5px; }
.src-item.sel { background: var(--btn-bg); color: var(--btn-txt); border-radius: 4px; }
/* карта объединения в Зоне 2 */
#macro-map { flex: 1; min-height: 300px; border: 1px solid var(--border); border-radius: 6px; }
/* --- переключатель карты РФ / Мир на Главной --- */
.map-mode { display: flex; gap: 6px; margin-bottom: 6px; }
.map-mode button { padding: 3px 14px; font-size: 12.5px; }

/* --- карта регионов (Главная): во всю ширину вкладки, без рамки --- */
#map { width: 100%; height: 72vh; min-height: 300px; }
#map-hint { margin-top: 6px; font-size: 13px; min-height: 18px; }
.db-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0 14px; font-size: 12.5px; color: var(--muted); }
.db-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* --- графики (ECharts) --- */
#charts-layout { display: flex; gap: 16px; align-items: flex-start; }
#chart-main { flex: 1; min-width: 0; height: 72vh; min-height: 320px; }
#chart-side { width: 230px; flex: none; display: flex; flex-direction: column; gap: 8px; }
#chart-side h3 { margin: 0; font-size: 15px; }
#chart-series-list { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.chart-series-item { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.chart-period { display: flex; flex-wrap: wrap; gap: 6px; }
.chart-period button { padding: 4px 8px; font-size: 12.5px; }
#chart-note { margin-top: auto; font-size: 12px; }

/* --- Данные: источники и каталог --- */
#src-info { display: flex; flex-direction: column; gap: 8px; }
.src-card { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 13px; background: var(--tab-bg); color: var(--tab-txt); }
#src-catalogs { display: flex; gap: 14px; align-items: flex-start; }
.src-col { flex: 1; min-width: 0; }
.src-col h4 { margin: 0 0 6px; font-size: 14px; }
.src-scroll { height: 376px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px;
  padding: 3px 8px; background: var(--tab-bg); color: var(--tab-txt); }
.src-item { font-size: 12.5px; line-height: 1.25; padding: 1.5px 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Зона «Первоисточники»: три отдельных скролла, РФ разделён на две части --- */
.sources-zone { border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  background: var(--zone-bg); color: var(--zone-txt); display: flex; flex-direction: column; gap: 8px; }
.zone-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.zone-head h3 { margin: 0; }
/* номер Зоны в правом верхнем углу */
.zone-num { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.zone-head .zone-num { margin-left: auto; }
.settings-zone .zone-num { position: absolute; top: 10px; right: 12px; }
.src-cols { display: flex; gap: 10px; align-items: stretch; }
.src-colbox { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.src-colbox.rf { flex: 1.5 1 0; }
.src-colcap { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.src-allchk { display: inline-flex; align-items: center; }
.src-allchk input { margin: 0; }
.src-drop { max-height: 280px; overflow-y: auto; flex: 1;
  border: 1px dashed transparent; border-radius: 6px; padding: 3px 8px; }
.src-drop.over { border-color: var(--border); background: color-mix(in srgb, var(--tab-sel) 35%, transparent); }
.src-drop .src-item { padding: 2px 6px; border-radius: 4px; display: flex; align-items: center; gap: 4px; }
.src-drop .src-item.child { padding-left: 20px; color: var(--muted); }
/* подсветка строки под курсором — чуть бледнее цвета кнопки */
.src-drop .src-item:hover { background: color-mix(in srgb, var(--btn-bg) 82%, #ffffff); border-radius: 4px; }
/* выбранная строка — цвет кнопки, текст — цвет текста кнопки */
.src-drop .src-item.sel, .src-drop .src-item.sel:hover { background: var(--btn-bg); color: var(--btn-txt); }
.src-exp { width: 15px; height: 15px; flex: none; padding: 0; line-height: 1;
  font-size: 11px; border: 1px solid var(--border); border-radius: 3px;
  background: var(--btn-bg); color: var(--btn-txt); cursor: pointer; }
.src-drop .src-item[draggable="true"] { cursor: grab; }
.src-drop .src-item.dragging { opacity: .4; }

/* --- компактные списки: фразы (Звук) и палитры (Цвет) --- */
.history { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.hist-item { border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; background: var(--tab-bg); font-size: 12.5px; color: var(--tab-txt); }
.hist-chips { display: flex; gap: 3px; margin: 4px 0; flex-wrap: wrap; }
.chip-mini { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }
.hist-actions { display: flex; gap: 6px; }
/* в истории тем «удалить» — у правого края бокса */
#history .hist-actions .hist-del { margin-left: auto; }
.hist-actions button, .hist-item button { padding: 1.5px 8px; font-size: 11.5px; }
.diagram-box { border: 1px solid var(--border); border-radius: 8px; padding: 14px;
  background: var(--tab-bg); overflow: auto; }
.diagram-box svg { width: 100%; height: auto; }

/* мини-схемы Области «Архитектура» (5×3 см) */
.minis-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.mini-card { width: 5cm; display: flex; flex-direction: column; gap: 4px; }
.mini-thumb { width: 5cm; height: 3cm; padding: 4px; background: var(--tab-bg);
  border-radius: 6px; box-shadow: 0 2px 5px rgba(0,0,0,.15); cursor: pointer; overflow: hidden; }
.mini-thumb:hover { filter: brightness(1.03); }
.mini-thumb svg { width: 100% !important; height: 100% !important; max-width: none !important; }
.mini-cap { font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.25; }

/* Окно: панель с крестиком, 80% пространства Области */
.app-window { position: absolute; width: 80%; height: 80%;
  background: var(--panel); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.35);
  display: flex; flex-direction: column; z-index: 80; }
.app-window-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  cursor: move; user-select: none; }
.app-window-head .title { font-weight: 600; font-size: 14px; color: var(--text); }
.app-window-head .win-spacer { flex: 1; }
.app-window-head .win-refresh { width: 24px; height: 24px; padding: 0; font-size: 14px; line-height: 1; }
.app-window-head .win-close { margin-left: 6px; width: 24px; height: 24px; padding: 0; font-size: 13px; line-height: 1; }
.app-window-body { flex: 1; overflow: auto; padding: 10px 14px 14px; background: var(--bg);
  border-radius: 0 0 10px 10px; }
.app-window-body svg { max-width: 100%; height: auto; }
.win-resize { position: absolute; right: 0; bottom: 0; width: 15px; height: 15px; cursor: nwse-resize;
  border-radius: 0 0 10px 0;
  background: linear-gradient(135deg, transparent 50%, var(--muted) 50% 58%, transparent 58% 68%, var(--muted) 68% 76%, transparent 76%);
  opacity: .55; }

/* Схема Проекта: реальные принтскрины, иерархия слева направо */
.scheme-wrap { overflow: hidden; }
.scheme-collage { position: relative; }
.ps-lines { position: absolute; left: 0; top: 0; z-index: 0; }
.ps-card { position: absolute; z-index: 1; display: flex; flex-direction: column; gap: 3px; }
.ps-screen { border: 1px solid #4a7cb5; border-radius: 6px; background: #fff; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.ps-bar { background: #eef4fc; color: #11376e; font-size: 11px; font-weight: 600;
  padding: 3px 6px; border-bottom: 1px solid #d5e3f2; }
.ps-body { height: 84px; padding: 4px; font-size: 9.5px; color: #11376e;
  display: flex; flex-direction: column; gap: 3px; background: #fff; overflow: hidden; }
.ps-body-s { height: 34px; justify-content: center; font-size: 10px; }
.ps-body-m { height: 52px; justify-content: center; font-size: 10.5px; font-weight: 600; }
.ps-menu-body { width: 164px; height: 500px; padding: 0; align-items: flex-start; background: var(--panel); }
.ps-img { width: 100%; height: 100%; object-fit: contain; background: #fff; display: block; }
.ps-desc { background: var(--tab-bg); color: var(--tab-txt); font-weight: 600; font-size: 10.5px;
  line-height: 1.3; border-radius: 4px; padding: 3px 5px; }
.ps-fit { overflow: hidden; }
.ps-dom { display: block !important; }
.ps-row { display: flex; align-items: center; gap: 4px; }
.ps-chip { font-size: 8.5px; background: #eef4fc; border: 1px solid #c7dbf0; color: #11376e;
  border-radius: 3px; padding: 1px 4px; }
.ps-map { width: 100%; height: auto; display: block; }
.ps-muted { color: #999; }
.ps-play { background: #0d4b96; color: #fff; border-radius: 4px; padding: 2px 6px;
  align-self: flex-start; font-size: 9px; }
.ps-bars { display: flex; align-items: flex-end; gap: 2px; height: 46px; }
.ps-bars i { width: 6px; background: #1976d2; border-radius: 1px 1px 0 0; }
.ps-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.ps-swatches i { height: 20px; border-radius: 2px; border: 1px solid rgba(0,0,0,.15); }
.ps-minis { display: flex; gap: 4px; }
.ps-minis i { width: 40px; height: 26px; background: #eef4fc; border: 1px solid #b8d2ec; border-radius: 3px; }
.ps-win-mini { font-size: 9px; border: 1px solid #b58a4a; background: #f7f3ec; border-radius: 4px;
  padding: 2px 5px; align-self: flex-start; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid var(--border); padding: 3px 6px; font-size: 12.5px; text-align: left; }

/* запрос разрешения на плановое обновление */
.update-prompt { position: fixed; right: 18px; bottom: 18px; z-index: 50; width: 330px;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  background: var(--panel); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  display: flex; flex-direction: column; gap: 8px; }
