:root {
	color-scheme: light dark;

	--c-psar: #000000;
	--c-psar2: #7e57c2;
	--c-smroc1: #800020;
	--c-ema1: #1f4fd8;
	--c-smroc2: #ff2222;
	--c-ema2: #7ec8e3;
	--c-smroc3: #0f7b3f;
	--c-ema3: #b8860b;
	--bg: #ffffff;
	--text: #1a1a1a;
	--border: rgba(128, 128, 128, .25);
}

:root[data-theme="dark"] {
	color-scheme: dark;
	--c-psar: #ffffff;
	--c-psar2: #b39ddb;
	--c-smroc1: #ff6b9d;
	--c-ema1: #6b9dff;
	--c-smroc2: #ff4444;
	--c-ema2: #9fd9ff;
	--c-smroc3: #4cd07d;
	--c-ema3: #e3b341;
	--bg: #161b26;
	--text: #d1d4dc;
	--border: rgba(128, 128, 128, .25);
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		color-scheme: dark;
		--c-psar: #ffffff;
		--c-psar2: #b39ddb;
		--c-smroc1: #ff6b9d;
		--c-ema1: #6b9dff;
		--c-smroc2: #ff4444;
		--c-ema2: #9fd9ff;
		--c-smroc3: #4cd07d;
		--c-ema3: #e3b341;
		--bg: #161b26;
		--text: #d1d4dc;
		--border: rgba(128, 128, 128, .25);
	}
}

* { box-sizing: border-box; }

body {
	margin: 0;
	font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
	background: var(--bg);
	color: var(--text);
}

a { color: #2f6fdf; }

/* Шапка */

.top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: .6rem 1.25rem;
	border-bottom: 1px solid rgba(128, 128, 128, .25);
}

.brand { font-weight: 600; color: inherit; text-decoration: none; }

.top nav a { text-decoration: none; }

.ticker { display: flex; align-items: center; gap: .4rem; color: #888; }

.ticker select { font: inherit; padding: .15rem .4rem; }

.theme-toggle { margin-left: auto; font: inherit; padding: .25rem .6rem; background: transparent; color: inherit; border: 1px solid rgba(128,128,128,.4); border-radius: 4px; cursor: pointer; }

/* Документация */

.doc main { max-width: 46rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.doc h1 { margin: 0 0 .5rem; font-size: 1.9rem; }

.doc h2 {
	margin: 2.2rem 0 .8rem;
	padding-bottom: .25rem;
	border-bottom: 1px solid rgba(128, 128, 128, .25);
	font-size: 1.35rem;
}

.doc h3 { margin: 1.6rem 0 .5rem; font-size: 1.1rem; }

.doc p { margin: .6rem 0; }

.doc ul, .doc ol { margin: .5rem 0; padding-left: 1.4rem; }

.doc li { margin: .2rem 0; }

.doc hr { margin: 2rem 0; border: 0; border-top: 1px solid rgba(128, 128, 128, .25); }

code {
	padding: .1rem .3rem;
	border-radius: 4px;
	background: rgba(128, 128, 128, .18);
	font-size: .9em;
}

/* Проверка стратегии */

.check { display: grid; grid-template-rows: auto 1fr; height: 100vh; }

.dates {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: .35rem;
	padding: .5rem 1.25rem;
	border-bottom: 1px solid rgba(128, 128, 128, .25);
}

.dates .ticker { margin-right: .75rem; }

.dates a {
	padding: .15rem .45rem;
	border-radius: 6px;
	color: inherit;
	text-decoration: none;
}

.dates a:hover { background: rgba(128, 128, 128, .18); }

.dates a.active { background: #2f6fdf; color: #fff; }

.layout {
	display: grid;
	grid-template-columns: 1fr 350px;
	gap: .75rem;
	padding: .75rem 1.25rem 1.25rem;
	min-height: 0;
}

.panel {
	position: relative;
	min-height: 0;
	border: 1px solid rgba(128, 128, 128, .25);
	border-radius: 8px;
	overflow: hidden;
}

#chart { position: absolute; inset: 0; }

.status {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #888;
	pointer-events: none;
}

.status.error { color: #d05252; }

.right { display: flex; flex-direction: column; gap: .75rem; min-height: 0; width: 350px; overflow-y: auto; }

.right > .params { flex: 0 0 auto; }

.right > .side { flex: 1 0 auto; min-height: 14rem; }

.params { padding: .75rem 1rem; }

.params h2 { margin: 0 0 .6rem; font-size: 1rem; }

.params ul { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }

.params li { display: grid; grid-template-columns: 18px 4.8rem 1fr; align-items: center; gap: .5rem; }

.params .swatch { height: 3px; border-radius: 2px; }

.params .name { font-size: .9rem; }

.params .value { color: #888; font-size: .85rem; }

.side { display: flex; flex-direction: column; min-height: 0; padding: .75rem 1rem; }

.signals { flex: 1; overflow: auto; display: grid; gap: .6rem; align-content: start; margin-bottom: .75rem; padding-right: .25rem; }

.signal { padding-bottom: .45rem; border-bottom: 1px solid rgba(128, 128, 128, .15); }

.signal-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; }

.signal-head .action { font-weight: 600; }

.signal-head .buy { color: #26a69a; }

.signal-head .short { color: #ef5350; }

.signal-head .close { color: #888888; }

.signal-values { display: flex; flex-wrap: wrap; gap: .15rem .7rem; margin-top: .2rem; font-size: .72rem; color: #888; }

.signal-values .ind { display: inline-flex; align-items: center; gap: .25rem; }

.signal-values i { width: 10px; height: 2px; border-radius: 1px; }

.profit { font-size: 1.15rem; }

.profit-percent { font-size: .8em; opacity: .75; }

.side h2.profit-title { margin-top: 0; }

.up { color: #26a69a; }

.down { color: #ef5350; }

.side h2 { margin: .2rem 0 .5rem; font-size: 1rem; }

.muted { color: #888; }

@media (max-width: 900px) {
	.check { height: auto; }
	.layout { grid-template-columns: 1fr; }
	.right { width: auto; overflow: visible; }
	.chart-panel { height: 60vh; }
	.dates a:not(.active):not(.date-prev):not(.date-next) {
		display: none;
	}
}

.params h2 { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.params-toggle { background: transparent; border: none; color: var(--text); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 .25rem; }
.params-toggle:hover { color: var(--accent); }
.params-form { display: grid; gap: .4rem; }
.params-form[hidden] { display: none; }
.param-row { display: grid; grid-template-columns: 6.5rem repeat(3, 1fr); align-items: center; gap: .4rem; font-size: .8rem; }
.param-name { display: flex; align-items: center; gap: .4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.param-name .swatch { height: 3px; border-radius: 2px; width: 14px; }
.swatch-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 18px;
	height: 18px;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: inherit;
	cursor: pointer;
	appearance: none;
}
.swatch-btn:disabled { cursor: default; opacity: 1; }
.swatch-btn:enabled:hover { background: rgba(128, 128, 128, .15); }
.swatch-btn:focus-visible { outline: 2px solid #2f6fdf; outline-offset: 1px; }
.params-form input { width: 100%; box-sizing: border-box; padding: .25rem .35rem; font-size: .8rem; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 4px; }
.params-form-actions { display: flex; justify-content: flex-end; }
.params-form-actions button { background: transparent; border: 1px solid var(--border); color: var(--text); padding: .25rem .5rem; font-size: .8rem; border-radius: 4px; cursor: pointer; }
.params-form-actions button:hover { border-color: var(--accent); }

.params-form input[readonly] { background: transparent; border-color: transparent; color: var(--text); }
.params-toggle:disabled { opacity: .4; cursor: default; }

.param-field { display: flex; align-items: center; gap: .3rem; }
.param-field input { flex: 1; min-width: 0; }
.param-label { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.params-form-actions { display: flex; justify-content: space-between; }
.params-cancel { margin-right: auto; }

.params-block { margin-top: .9rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.param-row.trailing { grid-template-columns: auto 1fr auto 1fr; }

/* Легенда нижней зоны сигналов: цвет полосы — источник сигнала. */
.params-legend {
	display: flex;
	flex-wrap: wrap;
	gap: .2rem .75rem;
	margin-top: .6rem;
	padding-top: .6rem;
	border-top: 1px solid var(--border);
	font-size: .75rem;
	color: var(--muted);
}

.params-legend span { display: inline-flex; align-items: center; gap: .3rem; }

.params-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }

/* Списки индикаторов и сигналов Тестера */

.config-add {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.55rem;
	height: 1.55rem;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: transparent;
	color: var(--text);
	font-size: 1rem;
	line-height: 1;
	cursor: pointer;
}

.config-add:hover { border-color: #2f6fdf; color: #2f6fdf; }

.config-list {
	display: grid;
	gap: .15rem;
	max-height: 28vh;
	overflow-y: auto;
	padding-right: .15rem;
}

.config-empty { margin: .15rem 0; color: #888; font-size: .8rem; }

.config-item {
	display: grid;
	grid-template-columns: 16px minmax(0, 1fr) auto;
	align-items: center;
	gap: .4rem;
	padding: .2rem .15rem;
	border-bottom: 1px solid var(--border);
	font-size: .8rem;
}

.config-item:last-child { border-bottom: 0; }

.config-item.signal-rule { grid-template-columns: 24px minmax(0, 1fr) auto auto; }

.signal-line-swatch { display: block; width: 22px; height: 4px; border-radius: 2px; }

.config-swatch { display: block; width: 14px; border-radius: 2px; }

.config-main { min-width: 0; }

.config-item-title {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: .8rem;
}

.config-icon {
	width: 1.4rem;
	height: 1.4rem;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: #888;
	font: inherit;
	line-height: 1;
	cursor: pointer;
}

.config-icon:hover { background: rgba(128, 128, 128, .15); color: var(--text); }

.config-more { width: 1.8rem; letter-spacing: .04em; }

.rule-action {
	font-size: .68rem;
	font-weight: 600;
	letter-spacing: .02em;
}

.rule-action.buy { color: #26a69a; }

.rule-action.sell { color: #ef5350; }

.config-note { margin: .5rem 0 0; color: #888; font-size: .72rem; line-height: 1.35; }

.dialog-params {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
	gap: .5rem;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }

.form-row-scale { grid-template-columns: 1fr 1fr; align-items: end; }

.form-row-name { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); align-items: end; }

.form-row-name .form-field input,
.form-row-name .form-field select { height: 2rem; }

.form-row-3 { grid-template-columns: 4rem 4.5rem minmax(0, 1fr); align-items: end; }

.form-row-3 .form-field input,
.form-row-3 .form-field select { height: 2rem; }

.form-row-signal { grid-template-columns: minmax(0, 1fr) 5rem; align-items: end; }

.form-row-signal .form-field select { height: 2rem; }

.signal-conditions-block { display: grid; gap: .35rem; }

.signal-conditions-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .5rem;
	color: #888;
	font-size: .78rem;
}

.condition-add {
	padding: .1rem .4rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: .75rem;
	cursor: pointer;
}

.condition-add:hover { border-color: #2f6fdf; color: #2f6fdf; }

.signal-conditions { display: grid; gap: .35rem; }

.condition-row {
	display: grid;
	grid-template-columns: minmax(0, 7rem) auto minmax(0, 7rem) auto;
	justify-content: start;
	align-items: center;
	gap: .4rem;
}

.condition-row select {
	width: 100%;
	padding: .35rem .45rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: .82rem;
}

.condition-word { color: #888; font-size: .8rem; white-space: nowrap; }

.condition-remove {
	width: 1.5rem;
	height: 1.5rem;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: #888;
	font: inherit;
	line-height: 1;
	cursor: pointer;
}

.condition-remove:hover { color: #d05252; background: rgba(128, 128, 128, .15); }

.condition-empty { margin: 0; color: #888; font-size: .8rem; }

.rule-action.close { color: #888; }

/* Админка */

.admin-layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.admin-menu { display: flex; flex-direction: column; gap: 1rem; padding: 1rem; border-right: 1px solid var(--border); }

.admin-menu .brand { font-weight: 600; color: inherit; text-decoration: none; }

.admin-menu-toggle { display: none; }

.menu-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.admin-menu nav { display: grid; gap: .15rem; }

.admin-menu nav a { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .4rem .6rem; border-radius: 6px; color: inherit; text-decoration: none; }

.admin-menu nav a:hover { background: rgba(128, 128, 128, .18); }

.admin-menu nav a.active { background: #2f6fdf; color: #fff; }

/* Счётчик непрочитанных сообщений чата. */
.menu-badge {
	min-width: 1.35rem;
	padding: 0 .35rem;
	border-radius: 999px;
	background: #d05252;
	color: #fff;
	font-size: .72rem;
	font-weight: 600;
	line-height: 1.35rem;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.menu-badge[hidden] { display: none; }

/* Разделы-заглушки: есть в меню, но ещё не работают. */
.admin-menu nav a.is-stub { color: #8a8f98; }

.admin-menu nav a.is-stub.active { background: #8a8f98; color: #fff; }

.admin-main { padding: 1.25rem 1.5rem 2rem; min-width: 0; }

.admin-main h1 { margin: 0 0 .5rem; font-size: 1.5rem; }

.admin-doc { max-width: 46rem; }

.admin-doc h1 { margin: 0 0 .5rem; font-size: 1.6rem; }

.admin-doc h2 { margin: 1.6rem 0 .6rem; padding-bottom: .2rem; border-bottom: 1px solid var(--border); font-size: 1.2rem; }

.admin-doc h3 { margin: 1.2rem 0 .4rem; font-size: 1.02rem; }

.admin-doc p { margin: .6rem 0; }

.admin-doc ul, .admin-doc ol { margin: .5rem 0; padding-left: 1.4rem; }

.admin-doc li { margin: .2rem 0; }

.admin-doc li.task { list-style: none; }

.admin-doc li.task input { margin: 0 .4rem 0 0; vertical-align: middle; }

.admin-doc hr { margin: 1.6rem 0; border: 0; border-top: 1px solid var(--border); }

/* Схема проекта на Главной. */
.admin-map { margin: 1.2rem 0 1.6rem; }

.admin-map .project-map { display: block; width: 100%; height: auto; color: #888; }

.admin-map .map-title { fill: var(--text); font-size: 13px; font-weight: 600; }

.admin-map .map-muted { fill: #888; font-size: 11px; }

.admin-map .map-link { color: #2f6fdf; }

.admin-map .map-link-muted { color: #888; }

.admin-doc .doc-table { width: 100%; margin: .8rem 0; border-collapse: collapse; }

.admin-doc .doc-table th,
.admin-doc .doc-table td { padding: .4rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }

.admin-doc .doc-table th { color: #888; font-size: .75rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }

.admin-doc .doc-table td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }

.admin-more { margin: .7rem 0 0; font-size: .88rem; }

/* Метрики на Главной: доходность и баланс. */

.admin-metrics {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	margin: 0 0 1rem;
}

.admin-metric {
	min-width: 0;
	padding: .85rem 1rem;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: rgba(128, 128, 128, .05);
}

.admin-metric-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: .75rem;
}

.admin-metric-label {
	color: #888;
	font-size: .72rem;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
}

.admin-metric-value {
	margin-top: .1rem;
	font-size: 1.5rem;
	font-weight: 600;
	line-height: 1.25;
	font-variant-numeric: tabular-nums;
}

.admin-metric-note { margin-top: .2rem; color: #888; font-size: .8rem; }

.admin-metric-link { flex: none; font-size: .85rem; }

@media (max-width: 720px) {
	.admin-metrics { grid-template-columns: minmax(0, 1fr); gap: .75rem; }
}

/* Фильтр задач дорожной карты. */

.roadmap-filter {
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .45rem;
	margin: 0 0 1rem;
	padding: .5rem .6rem;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--bg);
	box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

.roadmap-filter-label { color: #888; font-size: .8rem; }

.roadmap-filter-btn {
	display: inline-flex;
	align-items: center;
	gap: .4rem;
	padding: .25rem .6rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: .82rem;
	line-height: 1.3;
	cursor: pointer;
}

.roadmap-filter-btn:hover { border-color: #2f6fdf; }

.roadmap-filter-btn.is-active {
	border-color: #2f6fdf;
	background: #2f6fdf;
	color: #fff;
}

.roadmap-filter-count {
	min-width: 1.2rem;
	padding: 0 .3rem;
	border-radius: 999px;
	background: rgba(128, 128, 128, .16);
	font-size: .7rem;
	line-height: 1.2rem;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.roadmap-filter-btn.is-active .roadmap-filter-count { background: rgba(255, 255, 255, .22); }

.roadmap-filter-btn:focus-visible { outline: 2px solid #2f6fdf; outline-offset: 2px; }

.roadmap-filter-note {
	display: flex;
	flex-wrap: wrap;
	gap: .25rem;
	margin: -.45rem 0 1.2rem;
	padding: .55rem .75rem;
	border-left: 3px solid #2f6fdf;
	border-radius: 0 6px 6px 0;
	background: rgba(47, 111, 223, .06);
	font-size: .88rem;
	line-height: 1.45;
}

.roadmap-filter-note[hidden] { display: none; }

.roadmap-filter-note strong { font-weight: 600; }

.roadmap-current {
	margin: 1.1rem 0 1.2rem;
	padding: .75rem .95rem 1rem;
	border: 1px solid rgba(47, 111, 223, .28);
	border-left: 3px solid #2f6fdf;
	border-radius: 8px;
	background: rgba(47, 111, 223, .06);
}

.roadmap-current > h2 {
	margin-top: 0;
	border-bottom-color: rgba(47, 111, 223, .25);
}

.roadmap-current > p { margin-top: .45rem; }

.roadmap-current > ol { margin-bottom: 0; }

.admin-doc [hidden] { display: none; }

.admin-summary { display: flex; align-items: baseline; gap: .5rem; margin: 0 0 1rem; font-size: 1.1rem; }

.admin-summary-label { color: #888; }

.admin-summary-value { font-weight: 600; }

.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }

.admin-head h1 { margin: 0; }

.version-switch { display: flex; align-items: center; gap: .25rem; margin-left: auto; font-size: .8rem; }

.version-switch-item {
	padding: .2rem .55rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	color: inherit;
	text-decoration: none;
	line-height: 1.4;
}

a.version-switch-item:hover { border-color: #2f6fdf; color: #2f6fdf; }

.version-switch-item.is-active { background: var(--text); color: var(--bg); border-color: transparent; }

.tester-frame {
	display: block;
	width: 100%;
	height: calc(100vh - 7rem);
	min-height: 32rem;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--bg);
}

.icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: transparent;
	color: inherit;
	font: inherit;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
}

.icon-btn:hover { border-color: #2f6fdf; color: #2f6fdf; }

/* Таблицу не растягиваем на всю ширину: ширина по содержимому, но не больше 60rem. */
.table-wrap { max-width: 60rem; overflow-x: auto; }

.admin-table { width: auto; border-collapse: collapse; }

.admin-table th,
.admin-table td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }

.admin-table th { color: #888; font-size: .75rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }

.admin-table tbody tr:hover { background: rgba(128, 128, 128, .06); }

/* Процентная ширина колонки действий растягивала таблицу на всю доступную ширину. */
.admin-table th.actions,
.admin-table td.actions { white-space: nowrap; text-align: right; }

.admin-table td.profit-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }

.admin-table td.profit-cell a { font-weight: 600; }

.admin-table td.amount { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }

.admin-table td.date { white-space: nowrap; }

/* Раздел «Файлы»: название с пояснением и версия. */
.files-table td:first-child { min-width: 18rem; }

.files-name { font-weight: 600; }

.files-hint { margin-top: .15rem; color: #888; font-size: .8rem; }

.files-version { white-space: nowrap; color: #888; font-variant-numeric: tabular-nums; }

.admin-table .ticker-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }

.admin-table .code-cell { white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }

.table-empty { display: grid; justify-items: start; gap: .6rem; padding: .5rem 0; }

.table-empty p { margin: 0; }

.btn {
	padding: .3rem .65rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: .85rem;
	line-height: 1.3;
	text-decoration: none;
	cursor: pointer;
}

.btn:hover { border-color: #2f6fdf; }

.btn-primary { border-color: #2f6fdf; background: #2f6fdf; color: #fff; }

.btn-primary:hover { border-color: #2257b8; background: #2257b8; }

.btn-danger { border-color: rgba(208, 82, 82, .5); color: #d05252; }

.btn-danger:hover { border-color: #d05252; }

.form-errors { margin: 0 0 .75rem; color: #d05252; font-size: .85rem; white-space: pre-line; }

.form-dialog {
	width: min(48rem, calc(100vw - 2rem));
	max-height: calc(100dvh - 2rem);
	overflow: auto;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--bg);
	color: var(--text);
}

.form-dialog::backdrop { background: rgba(0, 0, 0, .45); }

.form-dialog--wide { width: min(80rem, calc(100vw - 2rem)); }

/* Две колонки в балоне: слева поля, справа описание на всю высоту. */
.dialog-columns {
	display: grid;
	grid-template-columns: 200px minmax(0, 1fr);
	gap: 1rem;
	align-items: stretch;
}

.dialog-col { display: grid; gap: .7rem; align-content: start; min-width: 0; }

.dialog-col--right { align-content: stretch; min-height: 26rem; }

.dialog-col--right .form-field { grid-template-rows: auto 1fr; }

.dialog-col--right .form-field textarea { height: 100%; min-height: 18rem; }

@media (max-width: 720px) {
	.dialog-columns { grid-template-columns: minmax(0, 1fr); }
	.dialog-col--right { min-height: 0; }
}

.dialog-form { display: grid; gap: .7rem; padding: 1rem 1.1rem; }

.dialog-form h2 { margin: 0 0 .2rem; font-size: 1.15rem; }

.form-meta { margin: 0 0 .2rem; color: #888; font-size: .8rem; }

.form-field { display: grid; gap: .25rem; }

.form-field span { color: #888; font-size: .75rem; }

.form-field input,
.form-field select,
.form-field textarea {
	width: 100%;
	padding: .4rem .5rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font: inherit;
}

.form-field textarea { min-height: 6rem; resize: vertical; }

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { border-color: #2f6fdf; outline: none; }

.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; margin-top: .3rem; }

.dialog-actions .btn-danger { margin-right: auto; }

.line-dialog { width: min(24rem, calc(100vw - 2rem)); }

.line-dialog .form-field input[type="color"] {
	width: 3rem;
	height: 2rem;
	padding: .15rem;
	cursor: pointer;
}

.line-dialog .form-row-3 .form-field input[type="color"] { width: 100%; }

.line-dialog .form-row-signal .form-field input[type="color"] { width: 100%; }

.line-preview {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 2.5rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: rgba(128, 128, 128, .05);
}

.line-preview i { display: block; width: 80%; height: 1px; border-radius: 999px; background: #888; }

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* Чат */

.chat {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	gap: .5rem;
	height: calc(100vh - 7.5rem);
	min-height: 26rem;
	max-width: 60rem;
	min-width: 0;
}

/* Чат занимает всю высоту окна, строка ввода — у нижнего края. */
body[data-section="chat"] .admin-layout { height: 100vh; height: 100dvh; grid-template-rows: minmax(0, 1fr); }

body[data-section="chat"] .admin-main { display: flex; flex-direction: column; min-height: 0; padding-bottom: 1rem; }

body[data-section="chat"] #app-content { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }

body[data-section="chat"] .chat { flex: 1; height: auto; min-height: 0; }

/* Быстрый чат устроен так же, как обычный: на всю высоту, ввод внизу. */
body[data-section="quick-chat"] .admin-layout { height: 100vh; height: 100dvh; grid-template-rows: minmax(0, 1fr); }

body[data-section="quick-chat"] .admin-main { display: flex; flex-direction: column; min-height: 0; padding-bottom: 1rem; }

body[data-section="quick-chat"] #app-content { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }

body[data-section="quick-chat"] .chat { flex: 1; height: auto; min-height: 0; }

.chat-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-width: 0; min-height: 2rem; }

.chat-toolbar-left { display: flex; align-items: center; gap: .25rem; min-width: 0; flex: 1; }

.chat-themes { display: flex; align-items: center; gap: .25rem; flex: 0 1 auto; min-width: 0; overflow-x: auto; padding-bottom: 2px; }

.chat-theme {
	display: inline-flex;
	align-items: center;
	gap: .35rem;
	flex: none;
	max-width: 14rem;
	padding: .28rem .55rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: .85rem;
	line-height: 1.3;
	white-space: nowrap;
	cursor: pointer;
}

.chat-theme-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-theme:hover { border-color: #2f6fdf; }

.chat-theme.is-active { background: #2f6fdf; border-color: #2f6fdf; color: #fff; }

.chat-theme-badge {
	min-width: 1.2rem;
	padding: 0 .3rem;
	border-radius: 999px;
	background: #d05252;
	color: #fff;
	font-size: .7rem;
	font-weight: 600;
	line-height: 1.2rem;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.chat-theme.is-active .chat-theme-badge { background: #fff; color: #2f6fdf; }

.chat-theme-add {
	flex: none;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 1px dashed var(--border);
	border-radius: 6px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
}

.chat-theme-add:hover { border-color: #2f6fdf; color: #2f6fdf; }

.chat-name-btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; flex: none; max-width: 18rem; }

.chat-name-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-name-icon { display: none; flex: none; width: 1.1rem; height: 1.1rem; }

.chat-name-icon svg { display: block; width: 100%; height: 100%; }

.chat-messages {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-height: 0;
	padding: .75rem;
	overflow-y: auto;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: rgba(128, 128, 128, .04);
}

.chat-empty { margin: auto; }

/* Когда сообщений мало, лента прижата к строке ввода. */
.chat-message:first-child { margin-top: auto; }

.chat-message {
	display: grid;
	grid-template-columns: 6.5rem minmax(0, 1fr);
	column-gap: .25rem;
	align-items: start;
	max-width: 100%;
}

/* Между группами разных авторов оставляем небольшой отступ. */
.chat-message.is-new-author:not(:first-child) { margin-top: .5rem; }

.chat-message-name {
	padding-top: .3rem;
	color: #888;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.5;
	text-align: right;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.chat-message-main {
	display: flex;
	align-items: flex-start;
	gap: .25rem;
	width: 100%;
	min-width: 0;
	max-width: 100%;
}

.chat-message-body {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: .2rem;
	position: relative;
	min-width: 0;
	max-width: min(38rem, 100%);
	padding: .3rem .6rem .35rem;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--bg);
}

/* Место под гамбургер в правом верхнем углу балуна. */
.chat-message-body.has-menu { padding-right: 2rem; }

.chat-message.is-own .chat-message-body {
	border-color: rgba(47, 111, 223, .4);
	background: rgba(47, 111, 223, .12);
}

.chat-message.is-deleted .chat-message-body { max-width: min(38rem, 100%); }

.chat-message.is-deleted .chat-message-text { color: #888; font-style: italic; }

.chat-message-quote {
	display: block;
	width: 100%;
	margin: 0;
	padding: .05rem .35rem;
	border: 0;
	border-left: 2px solid rgba(47, 111, 223, .5);
	border-radius: 0 4px 4px 0;
	background: transparent;
	color: #888;
	font: inherit;
	font-size: .78rem;
	line-height: 1.3;
	text-align: left;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	cursor: pointer;
}

.chat-message-quote:hover { background: rgba(128, 128, 128, .12); color: var(--text); }

.chat-message-quote:focus-visible { outline: 2px solid #2f6fdf; outline-offset: 1px; }

.chat-message-quote.is-static { cursor: default; }

.chat-message-quote.is-static:hover { background: transparent; color: #888; }

.chat-message.is-highlighted .chat-message-body { box-shadow: 0 0 0 2px #2f6fdf; }

.chat-message-line { display: flex; align-items: flex-end; gap: .75rem; min-width: 0; }

.chat-message-text { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.chat-message-text p { margin: 0; }

.chat-message-text p + p { margin-top: .5em; }

.chat-message-text a {
	color: #2f6fdf;
	text-decoration: underline;
	text-underline-offset: 2px;
	overflow-wrap: anywhere;
}

.chat-message-text a:hover { color: #1f4fd8; }

.chat-message.is-own .chat-message-text a { color: #1f4fd8; }

.chat-message-time { flex: none; color: #888; font-size: .7rem; line-height: 1.3; font-variant-numeric: tabular-nums; }

.chat-message-menu-wrap {
	position: absolute;
	top: .1rem;
	right: .1rem;
	z-index: 2;
	flex: none;
}

.chat-message-menu {
	width: 1.6rem;
	height: 1.6rem;
	padding: 0;
	border: 1px solid transparent;
	border-radius: 4px;
	background: transparent;
	color: #888;
	font: inherit;
	font-size: 1rem;
	line-height: 1;
	cursor: pointer;
}

.chat-message-menu:hover { background: rgba(128, 128, 128, .15); color: var(--text); }

.chat-message-menu-panel {
	position: absolute;
	top: 0;
	right: calc(100% + .35rem);
	z-index: 10;
	min-width: 7rem;
	padding: .2rem;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 6px;
	box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
}

.chat-message-menu-panel[hidden] { display: none; }

.chat-message-menu-item {
	display: block;
	width: 100%;
	padding: .35rem .5rem;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.chat-message-menu-item:hover { background: rgba(128, 128, 128, .15); }

.chat-message-menu-item.is-danger { color: #d05252; }

.chat-message-menu-item.is-danger:hover { background: rgba(208, 82, 82, .12); }

.chat-footer { display: grid; gap: .35rem; }

.chat-reply {
	display: flex;
	align-items: flex-start;
	gap: .5rem;
	padding: .35rem .5rem;
	border: 1px solid var(--border);
	border-left: 3px solid #2f6fdf;
	border-radius: 6px;
	background: rgba(128, 128, 128, .06);
}

.chat-reply[hidden] { display: none; }

.chat-reply-body { flex: 1; min-width: 0; }

.chat-reply-label { color: #888; font-size: .7rem; }

.chat-reply-text { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-reply-cancel {
	flex: none;
	width: 1.5rem;
	height: 1.5rem;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: #888;
	font: inherit;
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
}

.chat-reply-cancel:hover { background: rgba(128, 128, 128, .15); color: var(--text); }

.chat-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .5rem; }

.chat-form[hidden],
.chat-login[hidden],
.chat-name-btn[hidden] { display: none; }

.chat-form textarea {
	width: 100%;
	height: 2.35rem;
	min-height: 2.35rem;
	padding: .35rem .6rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: transparent;
	color: inherit;
	font: inherit;
	line-height: 1.5;
	resize: none;
}

.chat-form textarea:focus { border-color: #2f6fdf; outline: none; }

.chat-form .chat-send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .4rem;
	height: 2.35rem;
}

.chat-send-icon { display: none; flex: none; width: 1.1rem; height: 1.1rem; }

.chat-send-icon svg { display: block; width: 100%; height: 100%; fill: currentColor; }

.chat-error { margin: 0; color: #d05252; font-size: .85rem; white-space: pre-line; }

.chat-login {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .75rem;
	padding: .75rem;
	border: 1px dashed var(--border);
	border-radius: 8px;
}

/* Быстрый чат: подключение, статус цепочки и вспомогательные кнопки. */

.quick-chat-actions { display: flex; align-items: center; gap: .35rem; flex: none; min-width: 0; }

.quick-chat-note {
	flex: none;
	padding: .05rem .45rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	color: #888;
	font-size: .7rem;
	line-height: 1.5;
	white-space: nowrap;
}

.quick-chat-settings {
	flex: none;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 1rem;
	line-height: 1;
	cursor: pointer;
}

.quick-chat-settings:hover { border-color: #2f6fdf; color: #2f6fdf; }

.quick-chat-warning {
	margin: 0;
	padding: .35rem .55rem;
	border: 1px solid rgba(208, 82, 82, .35);
	border-radius: 6px;
	background: rgba(208, 82, 82, .08);
	color: #d05252;
	font-size: .82rem;
}

.quick-chat-feed { display: flex; flex-direction: column; gap: .4rem; min-width: 0; min-height: 0; }

.quick-chat-feed .chat-messages { flex: 1; }

/* В режиме подключения панели скрываются атрибутом hidden, а у них
   собственный display — без явного правила атрибут не сработает. */
.quick-chat .chat-toolbar[hidden],
.quick-chat .chat-footer[hidden],
.quick-chat .chat-messages[hidden],
.quick-chat .quick-chat-feed[hidden] { display: none; }

.quick-chat.is-setup { display: block; height: auto; min-height: 0; }

.quick-chat-setup {
	display: grid;
	gap: .75rem;
	max-width: 34rem;
	padding: 1rem;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: rgba(128, 128, 128, .04);
}

.quick-chat-setup[hidden] { display: none; }

.quick-chat-setup h2 { margin: 0; font-size: 1.1rem; }

.quick-chat-setup p { margin: 0; }

.quick-chat-setup-form { display: grid; gap: .6rem; }

.quick-chat-setup-fields { display: grid; gap: .6rem; }

.chat-message.is-missing .chat-message-text { color: #888; font-style: italic; }

.chat-message-retry {
	align-self: flex-start;
	margin-top: .2rem;
	padding: .15rem .45rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: transparent;
	color: #2f6fdf;
	font: inherit;
	font-size: .78rem;
	cursor: pointer;
}

.chat-message-retry:hover { border-color: #2f6fdf; }

.chat-messages .load-more {
	align-self: center;
	margin-bottom: .5rem;
	padding: .25rem .6rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: .8rem;
	cursor: pointer;
}

.chat-messages .load-more:hover { border-color: #2f6fdf; color: #2f6fdf; }

.chat-messages .load-more:disabled { opacity: .6; cursor: default; }

@media (max-width: 720px) {
	.roadmap-filter { position: static; }
	.admin-layout { grid-template-columns: minmax(0, 1fr); align-content: start; }
	.admin-menu {
		position: relative;
		z-index: 20;
		flex-direction: row;
		flex-wrap: nowrap;
		align-items: center;
		gap: .5rem;
		padding: .65rem 1rem;
		border-right: 0;
		border-bottom: 1px solid var(--border);
	}
	.admin-menu .brand { order: 1; flex: none; }
	.admin-menu nav { order: 2; display: flex; flex: 1; flex-wrap: nowrap; gap: .15rem; min-width: 0; overflow: hidden; }
	.admin-menu nav a { display: none; }
	.admin-menu nav a.active { display: flex; }
	.admin-menu-toggle {
		order: 3;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		flex: none;
		width: 2.25rem;
		height: 2.25rem;
		margin-left: auto;
		padding: 0;
		border: 1px solid var(--border);
		border-radius: 6px;
		background: transparent;
		color: inherit;
		font: inherit;
		font-size: 1.25rem;
		line-height: 1;
		cursor: pointer;
	}
	.admin-menu-toggle:hover { border-color: #2f6fdf; color: #2f6fdf; }
	.admin-menu.is-open nav {
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		display: grid;
		gap: .15rem;
		padding: .4rem .5rem .5rem;
		overflow: visible;
		background: var(--bg);
		border: 1px solid var(--border);
		border-top: 0;
		border-radius: 0 0 8px 8px;
		box-shadow: 0 8px 18px rgba(0, 0, 0, .18);
		z-index: 30;
	}
	.admin-menu.is-open nav a { display: flex; }
	.chat-messages { scrollbar-width: none; }
	.chat-messages::-webkit-scrollbar { display: none; }
	.chat-themes { scrollbar-width: none; }
	.chat-themes::-webkit-scrollbar { display: none; }
	.chat-form textarea { scrollbar-width: none; }
	.chat-form textarea::-webkit-scrollbar { display: none; }
	.chat-form .chat-send { width: 2.35rem; padding: 0; }
	.chat-send-label { display: none; }
	.chat-send-icon { display: block; }
	.chat-name-btn { width: 2.25rem; max-width: 2.25rem; height: 2.25rem; padding: 0; }
	.chat-name-label { display: none; }
	.chat-name-icon { display: block; }
	.tester-frame { height: calc(100vh - 12rem); }
	body[data-section="chat"] .admin-layout,
	body[data-section="quick-chat"] .admin-layout { grid-template-rows: auto minmax(0, 1fr); }
	.quick-chat-note { display: none; }
	.quick-chat-actions { gap: .15rem; }
	.quick-chat-settings { width: 2.25rem; height: 2.25rem; }
	.quick-chat-setup { padding: .75rem; }
	.chat-message {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: .1rem;
	}
	.chat-message-name {
		max-width: 100%;
		padding-top: 0;
		text-align: left;
	}
	.chat-message-name:empty { display: none; }
	.chat-message-body { align-self: flex-start; max-width: 100%; }
	.chat-name-btn { max-width: 8rem; }
}
