:root {
	--blue: #1a73e8;
	--blue-dark: #1557b0;
	--text: #1f2430;
	--text-soft: #6b7280;
	--border: #e5e8ee;
	--bg: #ffffff;
	--bg-soft: #f7f8fa;
	--green: #1e8e3e;
	--red: #d93025;
	--radius: 12px;
	--shadow: 0 1px 3px rgba(20, 30, 60, .08), 0 4px 16px rgba(20, 30, 60, .06);
}

* { box-sizing: border-box; }

body {
	margin: 0;
	font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
	background: var(--bg);
	color: var(--text);
	font-size: 15px;
}

.hidden { display: none !important; }

/* ---------- Кнопки ---------- */
.btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 9px 16px;
	border: 1px solid transparent;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	background: none;
	color: var(--text);
	transition: background .15s, border-color .15s, color .15s;
	white-space: nowrap;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-light { background: var(--bg); border-color: var(--border); }
.btn-light:hover { background: var(--bg-soft); }
.btn-ghost { padding: 6px; color: var(--text-soft); border-radius: 8px; }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn-danger { color: var(--red); border-color: transparent; }
.btn-danger:hover { background: #fdeceb; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- Авторизация ---------- */
.auth-screen {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--bg-soft);
	padding: 24px;
}
.auth-card {
	width: 100%;
	max-width: 400px;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 16px;
	box-shadow: var(--shadow);
	padding: 36px 32px;
	text-align: center;
}
.auth-logo { margin-bottom: 12px; }
.auth-card h1 { font-size: 22px; margin: 0 0 6px; }
.auth-sub { color: var(--text-soft); margin: 0 0 24px; font-size: 14px; }
.auth-card form { text-align: left; }
.auth-switch { margin-top: 20px; font-size: 14px; color: var(--text-soft); }
.auth-switch a { color: var(--blue); text-decoration: none; font-weight: 600; }

/* ---------- Формы ---------- */
label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	color: var(--text);
	margin-bottom: 14px;
}
label .hint { font-weight: 400; color: var(--text-soft); }
input[type="text"], input[type="password"], input[type="number"] {
	display: block;
	width: 100%;
	margin-top: 6px;
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-radius: 8px;
	font-size: 14px;
	font-family: inherit;
	background: var(--bg);
	color: var(--text);
	outline: none;
	transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26, 115, 232, .12); }
.form-error {
	background: #fdeceb;
	color: var(--red);
	border-radius: 8px;
	padding: 10px 12px;
	font-size: 13px;
	margin-bottom: 14px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.input-check { display: flex; gap: 8px; margin-top: 6px; }
.input-check input { margin-top: 0; flex: 1; min-width: 0; }
.check-result { display: block; font-weight: 400; font-size: 12px; margin-top: 5px; min-height: 15px; }
.check-result.ok { color: var(--green); }
.check-result.fail { color: var(--red); }

/* ---------- Каркас приложения ---------- */
.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 28px;
	border-bottom: 1px solid var(--border);
	background: var(--bg);
	position: sticky;
	top: 0;
	z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.topbar-user { display: flex; align-items: center; gap: 10px; color: var(--text-soft); font-size: 14px; }
.account-trigger {
	display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px;
	border: 1px solid transparent; border-radius: 999px; background: transparent;
	color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
	transition: background .15s, border-color .15s;
}
.account-trigger:hover { background: var(--bg-soft); border-color: var(--border); }
.account-avatar {
	display: inline-flex; align-items: center; justify-content: center; width: 29px; height: 29px;
	border-radius: 50%; background: linear-gradient(135deg, #1a73e8, #0b57d0); color: #fff;
	font-size: 13px; font-weight: 800; box-shadow: 0 3px 10px rgba(26,115,232,.2);
}

.content { max-width: 1080px; margin: 0 auto; padding: 32px 28px 64px; }
.content-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.content-head h2 { margin: 0; font-size: 24px; }

.bot-view-tabs {
	display: inline-flex; gap: 4px; padding: 4px; margin: -10px 0 22px;
	background: #f1f4f9; border: 1px solid #e1e6ee; border-radius: 12px;
}
.bot-view-tab {
	min-height: 40px; display: inline-flex; align-items: center; gap: 8px; padding: 8px 15px;
	border: 0; border-radius: 9px; background: transparent; color: var(--text-soft);
	font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
	transition: background .16s, color .16s, box-shadow .16s;
}
.bot-view-tab:hover { color: var(--text); background: rgba(255,255,255,.65); }
.bot-view-tab.active { background: #fff; color: var(--blue); box-shadow: 0 2px 8px rgba(31,49,79,.1); }
.bot-view-tab:focus-visible { outline: 3px solid rgba(26,115,232,.2); outline-offset: 1px; }

.monitor-summary {
	display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px;
}
.monitor-summary-card {
	position: relative; overflow: hidden; min-height: 92px; padding: 16px;
	border: 1px solid var(--border); border-radius: 13px; background: #fff;
	box-shadow: 0 3px 12px rgba(25,40,70,.045);
}
.monitor-summary-card::before {
	content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: #1a73e8;
}
.monitor-summary-card.green::before { background: #1e8e3e; }
.monitor-summary-card.orange::before { background: #e37400; }
.monitor-summary-card.violet::before { background: #7b61c9; }
.monitor-summary-card span { display: block; color: var(--text-soft); font-size: 12px; font-weight: 600; }
.monitor-summary-card strong { display: block; margin-top: 9px; color: var(--text); font-size: 23px; letter-spacing: -.02em; }
.monitor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.monitor-card {
	padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: #fff;
	box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s, border-color .18s;
}
.monitor-card:hover { transform: translateY(-2px); border-color: #d0d9e7; box-shadow: 0 8px 22px rgba(25,40,70,.1); }
.monitor-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.monitor-card-head h3 { margin: 0; font-size: 15px; word-break: break-word; }
.monitor-card-head p { margin: 3px 0 0; color: var(--text-soft); font-size: 12px; }
.monitor-owner {
	display: flex; justify-content: space-between; gap: 10px; margin: 14px 0; padding: 9px 11px;
	border-radius: 8px; background: #f7f9fc; font-size: 12px;
}
.monitor-owner span { color: var(--text-soft); }
.monitor-owner strong { color: var(--text); }
.monitor-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.monitor-metric { min-height: 74px; padding: 11px; border: 1px solid #e3e8f0; border-radius: 10px; background: #fbfcfe; }
.monitor-metric.memory { background: #fbf9ff; border-color: #e7e0f5; }
.monitor-metric-label { display: flex; flex-direction: column; gap: 5px; }
.monitor-metric-label span { color: var(--text-soft); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .035em; }
.monitor-metric-label strong { color: var(--text); font-size: 17px; }
.monitor-bar { height: 5px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: #e7ecf4; }
.monitor-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1a73e8, #55a1ff); transition: width .3s ease; }
.monitor-card-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 13px; color: #8993a3; font-size: 11px; }
.monitor-empty { padding: 54px 20px; border: 1px dashed var(--border); border-radius: 14px; color: var(--text-soft); text-align: center; }

/* ---------- Пустое состояние ---------- */
.empty { text-align: center; padding: 72px 24px; color: var(--text-soft); }
.empty h3 { color: var(--text); margin: 16px 0 6px; }
.empty p { max-width: 420px; margin: 0 auto; font-size: 14px; }

/* ---------- Карточки ботов ---------- */
.bots-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: 20px;
}
.bot-card {
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	box-shadow: var(--shadow);
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 14px;
}
.bot-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.bot-card-title { font-weight: 700; font-size: 16px; margin: 0; word-break: break-word; }
.bot-card-username { color: var(--text-soft); font-size: 13px; margin-top: 2px; }
.bot-status {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	font-weight: 700;
	padding: 4px 10px;
	border-radius: 999px;
	flex-shrink: 0;
}
.bot-status .dot { width: 7px; height: 7px; border-radius: 50%; }
.bot-status.running { background: #e6f4ea; color: var(--green); }
.bot-status.running .dot { background: var(--green); }
.bot-status.stopped { background: var(--bg-soft); color: var(--text-soft); }
.bot-status.stopped .dot { background: #9aa3b2; }
.bot-status.error { background: #fdeceb; color: var(--red); }
.bot-status.error .dot { background: var(--red); }

.bot-meta { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-soft); }
.bot-meta-row { display: flex; align-items: center; gap: 8px; }
.bot-meta-row svg { flex-shrink: 0; }

.bot-actions {
	display: grid; gap: 9px; border-top: 1px solid var(--border); padding-top: 14px; margin-top: auto;
}
.bot-runtime-actions, .bot-manage-actions, .bot-secondary-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bot-runtime-actions.single { grid-template-columns: 1fr; }
.bot-actions .bot-action {
	min-height: 44px; justify-content: flex-start; gap: 8px; padding: 9px 11px;
	border: 1px solid #dfe4ed; border-radius: 9px; background: #fff;
	color: #303847; font-size: 12.5px; font-weight: 700; box-shadow: 0 1px 2px rgba(20,30,50,.025);
}
.bot-actions .bot-action svg { width: 16px; height: 16px; flex: 0 0 auto; color: #657187; }
.bot-actions .bot-action:hover {
	background: #f4f8ff; border-color: #b9cff3; color: #1558ad;
	box-shadow: 0 3px 9px rgba(26,115,232,.09); transform: translateY(-1px);
}
.bot-actions .bot-action:hover svg { color: currentColor; }
.bot-actions .bot-action:focus-visible { outline: 3px solid rgba(26,115,232,.2); outline-offset: 1px; }
.bot-actions .btn-primary.bot-action { background: var(--blue); border-color: var(--blue); color: #fff; }
.bot-actions .btn-primary.bot-action svg { color: #fff; }
.bot-actions .btn-primary.bot-action:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.bot-actions .bot-action-stop { background: #fff9f5; border-color: #f2d7c7; color: #9a471d; }
.bot-actions .bot-action-stop svg { color: #b65a2b; }
.bot-actions .bot-action-stop:hover { background: #fff2e9; border-color: #e8b997; color: #873b16; }
.bot-actions .bot-action-restart { background: #f4f8ff; border-color: #cbdaf3; color: #185abc; }
.bot-actions .bot-action-restart svg { color: #185abc; }
.bot-secondary-actions { border-top: 1px dashed #e3e7ee; padding-top: 9px; margin-top: 1px; }
.bot-actions .bot-action-logs { background: #f8fafc; }
.bot-actions .bot-action-delete { background: transparent; border-color: transparent; color: #c23b32; box-shadow: none; }
.bot-actions .bot-action-delete svg { color: #d34a40; }
.bot-actions .bot-action-delete:hover { background: #fff0ef; border-color: #f3cbc7; color: #a92f28; box-shadow: none; }

/* ---------- Модалки ---------- */
.modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(25, 32, 45, .45);
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 5vh 16px;
	z-index: 100;
	overflow-y: auto;
}
.modal {
	width: 100%;
	max-width: 560px;
	background: var(--bg);
	border-radius: 16px;
	box-shadow: var(--shadow);
}
.modal-wide { max-width: 760px; }
.modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 24px;
	border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.form-section { margin-bottom: 20px; }
.form-section-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: var(--text-soft);
	margin-bottom: 12px;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--border);
}

.create-intro {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 14px;
	margin-bottom: 22px;
	border: 1px solid #cfe0fb;
	border-radius: 12px;
	background: #f3f7fe;
}
.create-intro-icon {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	border-radius: 10px;
	background: #fff;
	color: var(--blue);
	box-shadow: 0 1px 4px rgba(26, 115, 232, .12);
	flex: 0 0 auto;
}
.create-intro strong, .create-intro span, .create-progress strong, .create-progress span { display: block; }
.create-intro strong, .create-progress strong { font-size: 14px; }
.create-intro span, .create-progress span { margin-top: 3px; color: var(--text-soft); font-size: 12.5px; line-height: 1.45; }
.create-progress {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 14px;
	margin-bottom: 14px;
	border-radius: 10px;
	background: var(--bg-soft);
}
.create-spinner {
	width: 22px;
	height: 22px;
	border: 3px solid #d8e5f8;
	border-top-color: var(--blue);
	border-radius: 50%;
	animation: create-spin .75s linear infinite;
}
@keyframes create-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .create-spinner { animation-duration: 1.5s; } }

/* ---------- Логи ---------- */
.logs-body {
	margin: 0;
	padding: 20px 24px;
	max-height: 60vh;
	overflow: auto;
	font-family: 'Cascadia Mono', Consolas, monospace;
	font-size: 12px;
	line-height: 1.6;
	color: var(--text);
	background: var(--bg-soft);
	border-radius: 0 0 16px 16px;
	white-space: pre-wrap;
	word-break: break-all;
}

/* ---------- Toast ---------- */
.toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	background: var(--text);
	color: #fff;
	padding: 11px 20px;
	border-radius: 10px;
	font-size: 14px;
	box-shadow: var(--shadow);
	z-index: 200;
}

@media (max-width: 560px) {
	.form-row { grid-template-columns: 1fr; }
	.content { padding: 20px 16px 48px; }
	.topbar { padding: 12px 16px; }
}

/* ---------- Студия дизайна ---------- */
.modal-design { max-width: 1060px; }
.design-layout {
	display: grid;
	grid-template-columns: 1fr 380px;
	gap: 0;
}
.design-editor {
	padding: 20px 24px;
	max-height: 68vh;
	overflow-y: auto;
	border-right: 1px solid var(--border);
}
.design-themes-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.design-themes-bar select {
	flex: 1;
	padding: 9px 12px;
	border: 1px solid var(--border);
	border-radius: 8px;
	font-size: 14px;
	font-family: inherit;
	background: var(--bg);
	color: var(--text);
}
.color-input { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.color-input input[type="color"] {
	width: 38px;
	height: 38px;
	padding: 2px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--bg);
	cursor: pointer;
	flex-shrink: 0;
}
.color-input input[type="text"] { margin-top: 0; flex: 1; }
input[type="range"] { width: 100%; margin-top: 8px; accent-color: var(--blue); }
.check-label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check-label input { accent-color: var(--blue); width: 16px; height: 16px; }

.design-ms {
	border: 1px solid #cde8d3;
	background: #f2faf4;
	border-radius: 10px;
	padding: 12px 14px;
	margin-bottom: 16px;
	font-size: 13px;
}
.design-ms.design-ms-fail { border-color: #f5c9c5; background: #fdf1f0; }
.design-ms.design-ms-fail .design-ms-head svg { display: none; }
.design-ms-head { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.design-ms-body { color: var(--text-soft); margin-top: 6px; line-height: 1.6; }
.design-ms-body b { color: var(--text); }

.design-rule {
	display: grid;
	grid-template-columns: 1fr 1fr auto;
	gap: 8px;
	margin-bottom: 10px;
	align-items: center;
}
.design-rule select, .design-rule input {
	margin-top: 0 !important;
	padding: 8px 10px;
	border: 1px solid var(--border);
	border-radius: 8px;
	font-size: 13px;
	font-family: inherit;
	background: var(--bg);
	color: var(--text);
	width: 100%;
}
.design-actions { padding: 14px 24px; border-top: 1px solid var(--border); align-items: center; margin-top: 0; }
.design-actions .hint { margin-right: auto; font-size: 13px; color: var(--text-soft); }

/* ---------- iPhone 17 Pro Max превью ---------- */
.design-preview {
	background: var(--bg-soft);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 28px 20px;
}
.iphone {
	position: relative;
	width: 300px;
	height: 620px;
	background: #0a0a0a;
	border-radius: 52px;
	padding: 9px;
	box-shadow:
		0 0 0 2.5px #3a3a3c,
		0 0 0 4px #1a1a1a,
		0 24px 48px rgba(15, 25, 45, .35);
}
.iphone-island {
	position: absolute;
	top: 22px;
	left: 50%;
	transform: translateX(-50%);
	width: 92px;
	height: 26px;
	background: #000;
	border-radius: 999px;
	z-index: 5;
}
.iphone-screen {
	width: 100%;
	height: 100%;
	background: #f4f5f7;
	border-radius: 44px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	position: relative;
}
.iphone-statusbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 26px 4px;
	font-size: 13px;
	font-weight: 700;
	color: #0a0a0a;
}
.iphone-status-icons { display: flex; align-items: center; gap: 5px; color: #0a0a0a; }
.phone-app-head {
	padding: 16px 20px 8px;
	font-size: 17px;
	font-weight: 800;
	color: #14171c;
}
.phone-hint {
	margin-top: auto;
	text-align: center;
	padding: 14px;
	font-size: 11px;
	color: #9aa3b2;
}

/* карта лояльности в превью */
.loyalty-card {
	position: relative;
	margin: 8px 14px;
	border-radius: 20px;
	overflow: hidden;
	background: linear-gradient(180deg, #0b0b0b 0%, #000 100%);
	color: #fff;
	aspect-ratio: 1.586;
	box-shadow: 0 10px 26px rgba(10, 15, 30, .35);
}
.loyalty-card-bgimg {
	position: absolute;
	inset: 0;
	background-size: cover;
	background-position: center;
	opacity: 0;
}
.loyalty-card-overlay { position: absolute; inset: 0; }
.loyalty-card-inner {
	position: relative;
	z-index: 2;
	height: 100%;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	padding: 16px;
}
.loyalty-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.loyalty-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.loyalty-logo { height: 34px; max-width: 90px; object-fit: contain; border-radius: 7px; }
.loyalty-brand-title { font-size: 15px; font-weight: 800; letter-spacing: .02em; line-height: 1.15; }
.loyalty-brand-sub { font-size: 10px; opacity: .75; margin-top: 2px; }
.loyalty-balance { text-align: right; flex-shrink: 0; }
.loyalty-balance-label { font-size: 9px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; }
.loyalty-balance-value { font-size: 22px; font-weight: 800; line-height: 1.1; }
.loyalty-bottom { display: flex; align-items: flex-end; gap: 10px; }
.loyalty-owner { font-size: 12px; font-weight: 600; opacity: .92; flex: 1; }
.loyalty-pill {
	font-size: 10px;
	font-weight: 800;
	padding: 3px 8px;
	border-radius: 999px;
	background: rgba(255, 255, 255, .18);
	backdrop-filter: blur(4px);
}
.loyalty-qr {
	position: relative;
	width: 52px;
	height: 52px;
	background: #fff;
	border-radius: 9px;
	padding: 5px;
	flex-shrink: 0;
}
.loyalty-qr-logo {
	position: absolute;
	inset: 0;
	margin: auto;
	width: 30%;
	height: 30%;
	object-fit: contain;
	background: #fff;
	border-radius: 4px;
	padding: 2px;
}

@media (max-width: 900px) {
	.design-layout { grid-template-columns: 1fr; }
	.design-preview { order: -1; padding: 18px; }
	.iphone { width: 240px; height: 500px; border-radius: 44px; }
	.design-editor { border-right: none; max-height: none; }
}

/* ---------- Редактор мини-приложения ---------- */
.ma-section-flash {
	animation: ma-flash 1.2s ease;
	border-radius: 10px;
}
@keyframes ma-flash {
	0% { box-shadow: 0 0 0 3px rgba(26, 115, 232, .45); background: rgba(26, 115, 232, .07); }
	100% { box-shadow: 0 0 0 3px rgba(26, 115, 232, 0); background: transparent; }
}
.ma-collapse summary {
	cursor: pointer;
	user-select: none;
	list-style: none;
}
.ma-collapse summary::-webkit-details-marker { display: none; }
.ma-collapse summary::after {
	content: '▸';
	margin-left: 6px;
	color: var(--text-soft);
	font-size: 12px;
	transition: transform .15s;
	display: inline-block;
}
.ma-collapse[open] summary::after { transform: rotate(90deg); }
.ma-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ma-prize {
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 10px;
	margin-bottom: 8px;
	background: var(--bg-soft);
}
.ma-prize-row {
	display: grid;
	grid-template-columns: 2fr 1fr auto;
	gap: 8px;
}
.ma-prize-row + .ma-prize-row { margin-top: 8px; grid-template-columns: 1fr 1fr 1.4fr; }
.ma-prize input, .ma-prize select {
	margin-top: 0 !important;
	padding: 8px 10px;
	font-size: 13px;
}
.ma-code {
	display: block;
	width: 100%;
	margin-top: 6px;
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-radius: 8px;
	font-family: 'Cascadia Mono', Consolas, monospace;
	font-size: 12.5px;
	line-height: 1.5;
	background: var(--bg-soft);
	color: var(--text);
	resize: vertical;
	outline: none;
}
.ma-code:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26, 115, 232, .12); }
.ma-text-row {
	display: grid;
	grid-template-columns: 1fr 1fr auto;
	gap: 8px;
	margin-bottom: 8px;
}
.ma-text-row input {
	margin-top: 0 !important;
	padding: 8px 10px;
	font-size: 13px;
}
.iphone-screen-app { background: #fff; position: relative; }
/* Приложение рендерится в реальной ширине телефона (390px) и масштабируется под рамку,
   иначе вёрстка мини-приложения не помещается и обрезается */
.ma-frame {
	position: absolute;
	top: 0;
	left: 0;
	transform-origin: top left;
	border: none;
	border-radius: 0;
	background: #fff;
}
.ma-frame-off {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	background: #f4f5f7;
	border-radius: 44px;
	text-align: center;
	font-size: 13px;
	color: var(--text-soft);
	z-index: 4;
	padding: 24px;
}

/* ---------- Админ-панель ---------- */
.account-modal { max-width: 720px; }
.account-subtitle { margin: 3px 0 0; color: var(--text-soft); font-size: 13px; }
.account-body { display: grid; gap: 16px; background: #f7f9fc; }
.account-section {
	background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 18px;
	box-shadow: 0 3px 12px rgba(32,44,69,.04);
}
.account-section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.account-section-head h4 { margin: 0 0 3px; font-size: 15px; }
.account-section-head p { margin: 0; color: var(--text-soft); font-size: 12.5px; }
.account-section-icon {
	width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
	background: #e8f0fe; color: var(--blue); flex: 0 0 auto;
}
.account-section-icon.green { background: #e6f4ea; color: #188038; }
.account-password-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.account-password-form label:first-child { grid-column: 1 / -1; }
.account-password-form .form-error, .account-password-form .btn { grid-column: 1 / -1; }
.account-password-form .btn { justify-self: start; }
.sessions-heading #sessions-revoke-all { margin-left: auto; white-space: nowrap; }
.sessions-list { display: grid; gap: 9px; }
.session-item {
	display: flex; align-items: center; gap: 12px; padding: 12px;
	border: 1px solid var(--border); border-radius: 11px; background: #fff;
}
.session-item.current { border-color: #b7dfc2; background: #f6fbf7; }
.session-device-icon {
	width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
	background: var(--bg-soft); color: var(--text-soft); flex: 0 0 auto;
}
.session-item.current .session-device-icon { background: #e6f4ea; color: #188038; }
.session-info { min-width: 0; flex: 1; }
.session-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.session-current {
	display: inline-block; margin-left: 6px; padding: 2px 7px; border-radius: 999px;
	background: #d9f2df; color: #137333; font-size: 10px; font-weight: 800; vertical-align: 1px;
}
.session-meta, .session-created { color: var(--text-soft); font-size: 11.5px; margin-top: 3px; overflow-wrap: anywhere; }
.session-created { color: #8a94a3; }
.session-revoke { flex: 0 0 auto; }
@media (max-width: 620px) {
	.account-password-form { grid-template-columns: 1fr; }
	.account-password-form label:first-child { grid-column: auto; }
	.sessions-heading { align-items: flex-start; flex-wrap: wrap; }
	.sessions-heading #sessions-revoke-all { margin-left: 50px; }
	.session-item { align-items: flex-start; flex-wrap: wrap; }
	.session-revoke { margin-left: 50px; }
	.account-trigger svg { display: none; }
}
.admin-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
	gap: 12px;
	margin-bottom: 20px;
}
.admin-stat {
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 14px;
	text-align: center;
}
.admin-stat-value { font-size: 26px; font-weight: 800; color: var(--blue); }
.admin-stat-label { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.admin-subhead { margin: 20px 0 10px; font-size: 15px; }
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
	text-align: left;
	padding: 10px 12px;
	background: var(--bg-soft);
	color: var(--text-soft);
	font-weight: 700;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}
.admin-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .btn { padding: 4px 10px; font-size: 12px; }

/* ---------- Редактор сообщений бота ---------- */
#messages-modal .modal-wide { max-width: 1000px; }
.messages-layout { display: grid; grid-template-columns: 1fr 340px; gap: 22px; }
@media (max-width: 900px) { .messages-layout { grid-template-columns: 1fr; } }

.msg-tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.msg-tab {
	padding: 7px 14px; border: 1px solid var(--border); border-radius: 20px;
	background: var(--bg); font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text-soft);
}
.msg-tab.active { background: var(--blue); border-color: var(--blue); color: #fff; }

#msg-text {
	width: 100%; border: 1px solid var(--border); border-radius: 8px;
	padding: 10px 12px; font: inherit; resize: vertical; min-height: 140px;
}
#msg-text:focus { outline: none; border-color: var(--blue); }

.msg-menu-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.menu-row {
	display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
	padding: 8px; border: 1px dashed var(--border); border-radius: 8px; margin-bottom: 8px;
}
.menu-btn {
	display: flex; gap: 4px; align-items: center;
	background: var(--bg-soft); border-radius: 8px; padding: 4px;
}
.menu-btn input[type="text"] { width: 130px; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.menu-btn select { border: 1px solid var(--border); border-radius: 6px; padding: 6px 4px; font-size: 12px; background: #fff; }
.menu-btn [data-f="url"] { width: 120px; }
.menu-btn .btn-danger { padding: 4px 8px; }
.menu-add-btn { padding: 5px 10px; font-size: 12px; }

/* Превью чата Telegram */
.messages-preview { position: sticky; top: 0; }
.tg-chat {
	border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
	background: #8db2d6 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" opacity="0.06"><circle cx="30" cy="30" r="14" fill="white"/></svg>');
	display: flex; flex-direction: column; min-height: 480px;
}
.tg-chat-head {
	display: flex; align-items: center; gap: 10px;
	background: #517da2; color: #fff; padding: 10px 14px;
}
.tg-avatar {
	width: 36px; height: 36px; border-radius: 50%; background: #e17076;
	display: flex; align-items: center; justify-content: center;
	font-weight: 700; color: #fff; font-size: 16px;
}
.tg-chat-name { font-weight: 600; font-size: 14px; }
.tg-chat-status { font-size: 12px; opacity: .8; }
.tg-chat-body { padding: 14px 10px; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; }
.tg-bubble {
	background: #fff; border-radius: 12px 12px 12px 4px; padding: 8px 12px 6px;
	max-width: 92%; position: relative; box-shadow: 0 1px 1px rgba(0,0,0,.12);
}
.tg-msg-text { font-size: 13.5px; line-height: 1.35; white-space: normal; word-break: break-word; }
.tg-msg-footer { font-size: 11.5px; color: #8a94a0; margin-top: 8px; font-style: italic; }
.tg-msg-time { font-size: 10.5px; color: #9ab; text-align: right; margin-top: 2px; }
.tg-kb { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; max-width: 92%; }
.tg-kb-row { display: flex; gap: 4px; }
.tg-kb-btn {
	flex: 1; border: none; border-radius: 8px; cursor: default;
	background: rgba(255,255,255,.92); color: #3a6d99;
	padding: 8px 6px; font-size: 12.5px; font-weight: 600;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Анимации ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(26px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.modal-backdrop { animation: fadeIn .18s ease-out; }
.modal { animation: slideUp .24s cubic-bezier(.2,.8,.25,1); }
.bot-card { animation: cardIn .3s ease-out backwards; transition: box-shadow .2s, transform .2s, border-color .2s; }
.bot-card:nth-child(2) { animation-delay: .05s; }
.bot-card:nth-child(3) { animation-delay: .1s; }
.bot-card:nth-child(4) { animation-delay: .15s; }
.bot-card:nth-child(n+5) { animation-delay: .2s; }
.bot-card:hover { box-shadow: 0 6px 20px rgba(20,30,60,.12), 0 2px 6px rgba(20,30,60,.08); transform: translateY(-2px); border-color: #d5dbe6; }
.btn { transition: background .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s; }
.btn:active { transform: scale(.96); }
.btn-primary:hover { box-shadow: 0 4px 12px rgba(26,115,232,.35); }
.toast { animation: toastIn .25s cubic-bezier(.2,.8,.25,1); }
.bot-status.running .dot { animation: pulse 1.6s ease-in-out infinite; }
.msg-tab, .tg-kb-btn, .menu-btn { transition: background .15s, color .15s, border-color .15s; }
.auth-card { animation: slideUp .3s cubic-bezier(.2,.8,.25,1); }
.empty { animation: fadeIn .4s ease-out; }
input, textarea, select { transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 3px rgba(26,115,232,.12); }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Мобильная версия ---------- */
@media (max-width: 560px) {
	.bots-grid { grid-template-columns: 1fr; gap: 14px; }
	.bot-actions .btn { flex: 1 1 44%; justify-content: center; }
	.modal-backdrop { padding: 0; align-items: flex-end; }
	.modal, .modal-wide, .modal-design {
		max-width: 100%;
		border-radius: 16px 16px 0 0;
		max-height: 94vh;
		overflow-y: auto;
		animation: slideUp .28s cubic-bezier(.2,.8,.25,1);
	}
	.modal-head { position: sticky; top: 0; background: var(--bg); z-index: 5; border-radius: 16px 16px 0 0; }
	.modal-body { padding: 18px 16px; }
	.modal-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; margin-top: 0; }
	.modal-actions .btn { flex: 1; justify-content: center; }
	.content-head { flex-wrap: wrap; gap: 12px; }
	.msg-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
	.msg-tab { white-space: nowrap; flex-shrink: 0; }
	.menu-btn { flex-wrap: wrap; }
	.menu-btn input[type="text"] { width: 110px; }
	.tg-chat { min-height: 380px; }
	.messages-preview { position: static; }
	.input-check { flex-wrap: wrap; }
	h2 { font-size: 20px; }
	.bot-view-tabs { display: flex; margin-top: -6px; }
	.bot-view-tab { flex: 1; justify-content: center; min-height: 44px; }
	.monitor-summary { grid-template-columns: 1fr 1fr; gap: 9px; }
	.monitor-summary-card { min-height: 82px; padding: 13px; }
	.monitor-summary-card strong { font-size: 19px; }
	.monitor-grid { grid-template-columns: 1fr; }
}

/* ---------- Анимации: закрытие модалок, доп. эффекты ---------- */
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideDown { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(22px) scale(.98); } }

.modal-backdrop.closing { animation: fadeOut .18s ease-in forwards; pointer-events: none; }
.modal-backdrop.closing .modal { animation: slideDown .18s ease-in forwards; }

/* повторные перерисовки списка — без анимации появления (нет «мигания») */
.bots-grid.no-anim .bot-card { animation: none; }

/* плавная смена статуса бота */
.bot-status { transition: background .3s, color .3s; }
.bot-status .dot { transition: background .3s; }

/* кнопки в Telegram-превью «нажимаются» */
.tg-kb-btn { transition: background .15s, transform .1s; }
.tg-kb-btn:hover { background: #fff; }
.tg-kb-btn:active { transform: scale(.97); }

/* сообщение в превью плавно обновляется */
.tg-bubble { animation: cardIn .25s ease-out; }

/* переключение вкладок сообщений */
.msg-tab { transform: translateZ(0); }
.msg-tab:hover { border-color: var(--blue); color: var(--blue); }
.msg-tab.active:hover { color: #fff; }

/* появление рядов кнопок в редакторе меню */
.menu-row { animation: cardIn .2s ease-out; }

/* топбар: лёгкая тень при прокрутке уже есть у карточек; иконка логотипа */
.topbar svg:first-child { transition: transform .3s; }
.topbar:hover svg:first-child { transform: rotate(-8deg) scale(1.06); }

/* тост исчезает мягко */
.toast { transition: opacity .25s, transform .25s; }

/* строки таблицы админки */
.admin-table tr { transition: background .15s; }
