/* Цвета берём из темы Telegram, чтобы приложение выглядело родным
   и в тёмной, и в светлой теме. */
:root {
	--bg: var(--tg-theme-bg-color, #101720);
	--text: var(--tg-theme-text-color, #f2f5f9);
	--muted: var(--tg-theme-hint-color, #8d9aad);
	--card: var(--tg-theme-secondary-bg-color, #18212e);
	--accent: var(--tg-theme-button-color, #3d8bfd);
	--accent-text: var(--tg-theme-button-text-color, #ffffff);
	--link: var(--tg-theme-link-color, #6ab3ff);

	--line: rgba(127, 137, 155, 0.28);
	--field: rgba(127, 137, 155, 0.12);
	--soft: rgba(127, 137, 155, 0.08);

	--green: #2ecc71;
	--yellow: #f0b429;
	--red: #ff5a5f;

	--radius: 16px;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
	font-size: 16px;
	line-height: 1.45;
	-webkit-text-size-adjust: 100%;
}

.wrap {
	max-width: 560px;
	margin: 0 auto;
	padding: 12px 12px calc(28px + env(safe-area-inset-bottom));
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* ===== шапка ===== */

.head {
	position: relative;
	overflow: hidden;
	padding: 20px 18px;
	border-radius: 18px;
	background: linear-gradient(135deg, #2f6df6 0%, #3a7bf0 45%, #2fb8a4 100%);
	color: #fff;
}

.head::after {
	content: "";
	position: absolute;
	right: -60px;
	top: -70px;
	width: 200px;
	height: 200px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.14);
}

.head h1 {
	margin: 0;
	font-size: 27px;
	letter-spacing: -0.5px;
}

.head .sub {
	margin: 6px 0 0;
	font-size: 14px;
	opacity: 0.92;
	position: relative;
	z-index: 1;
}

/* ===== вкладки ===== */

.tabs {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 4px;
	padding: 4px;
	border-radius: 14px;
	background: var(--card);
}

.tab {
	padding: 10px 6px;
	border: 0;
	border-radius: 11px;
	background: transparent;
	color: var(--muted);
	font-size: 15px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.tab.active {
	background: var(--accent);
	color: var(--accent-text);
	box-shadow: 0 4px 12px rgba(47, 109, 246, 0.28);
}

/* ===== карточки ===== */

.card {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.card h2 {
	margin: 0;
	font-size: 17px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}

/* ===== поля ввода ===== */

.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.grid2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.label {
	font-size: 13px;
	font-weight: 600;
	color: var(--muted);
}

.hint {
	margin: 0;
	font-size: 12.5px;
	color: var(--muted);
}

input,
select {
	width: 100%;
	padding: 12px 13px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--field);
	color: var(--text);
	font-size: 16px;
	font-family: inherit;
	outline: none;
	transition: border-color 0.15s ease;
}

input:focus,
select:focus {
	border-color: var(--accent);
}

input::placeholder {
	color: var(--muted);
	opacity: 0.75;
}

/* Стрелка у select нарисована градиентами: без картинок и шрифтов. */
select {
	-webkit-appearance: none;
	appearance: none;
	padding-right: 34px;
	background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
		linear-gradient(135deg, var(--muted) 50%, transparent 50%);
	background-position: calc(100% - 19px) calc(50% + 1px), calc(100% - 14px) calc(50% + 1px);
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
}

/* ===== кнопки ===== */

.primary,
.ghost {
	padding: 14px 16px;
	border-radius: 13px;
	font-size: 16px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	transition: transform 0.08s ease, opacity 0.15s ease;
}

.primary {
	border: 0;
	background: var(--accent);
	color: var(--accent-text);
	box-shadow: 0 6px 16px rgba(47, 109, 246, 0.26);
}

.ghost {
	border: 1px solid var(--accent);
	background: transparent;
	color: var(--link);
}

.primary:active,
.ghost:active {
	transform: scale(0.985);
}

.primary:disabled,
.ghost:disabled {
	opacity: 0.6;
	cursor: default;
}

.row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.spinner {
	width: 14px;
	height: 14px;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	display: inline-block;
	animation: spin 0.7s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* ===== результат проверки ===== */

.verdict {
	display: flex;
	align-items: center;
	gap: 12px;
}

.light {
	font-size: 32px;
	line-height: 1;
}

.verdict-title {
	font-size: 17px;
	font-weight: 700;
}

.score {
	margin-left: auto;
	padding: 5px 11px;
	border-radius: 999px;
	background: var(--field);
	font-size: 13px;
	font-weight: 700;
	white-space: nowrap;
}

.bar {
	height: 7px;
	border-radius: 999px;
	background: var(--soft);
	overflow: hidden;
}

.bar span {
	display: block;
	height: 100%;
	width: 0;
	border-radius: 999px;
	background: var(--muted);
	transition: width 0.4s ease;
}

.bar.green span {
	background: var(--green);
}

.bar.yellow span {
	background: var(--yellow);
}

.bar.red span {
	background: var(--red);
}

.layers,
.flags,
.history,
.ops,
.checklist {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.layers li,
.history li {
	display: flex;
	align-items: center;
	gap: 9px;
	font-size: 14.5px;
}

.history li {
	padding-bottom: 8px;
	border-bottom: 1px solid var(--line);
}

.history li:last-child {
	border-bottom: 0;
	padding-bottom: 0;
}

.history li .mono {
	flex: 1;
}

/* Уровни флагов приходят из risk.js как red/yellow. */
.flag {
	padding: 10px 12px;
	border-radius: 11px;
	border-left: 3px solid var(--muted);
	background: var(--soft);
	font-size: 14.5px;
}

.flag.red,
.flag.critical {
	border-left-color: var(--red);
	background: rgba(255, 90, 95, 0.13);
}

.flag.yellow,
.flag.warning {
	border-left-color: var(--yellow);
	background: rgba(240, 180, 41, 0.13);
}

/* ===== журнал операций ===== */

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.chip {
	padding: 7px 11px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: transparent;
	color: var(--muted);
	font-size: 12.5px;
	font-family: inherit;
	cursor: pointer;
	text-align: left;
}

.chip.on {
	border-color: var(--accent);
	background: rgba(61, 139, 253, 0.14);
	color: var(--text);
}

.ops li {
	position: relative;
	padding: 12px 12px 12px 14px;
	border-radius: 12px;
	border-left: 3px solid var(--muted);
	background: var(--soft);
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.ops li.in {
	border-left-color: var(--green);
}

.ops li.out {
	border-left-color: var(--red);
}

.ops li.none {
	border-left-color: var(--muted);
}

.op-head {
	display: flex;
	align-items: baseline;
	gap: 8px;
	font-size: 14.5px;
	font-weight: 600;
}

.op-head .amount {
	margin-left: auto;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.op-purpose {
	font-size: 13px;
	color: var(--muted);
}

.del {
	align-self: flex-start;
	margin-top: 2px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--red);
	font-size: 12.5px;
	font-family: inherit;
	cursor: pointer;
}

/* ===== налоги ===== */

.kpis {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}

.kpi {
	padding: 12px;
	border-radius: 12px;
	background: var(--soft);
}

.kpi.accent {
	background: linear-gradient(135deg, rgba(47, 109, 246, 0.22), rgba(47, 184, 164, 0.22));
	border: 1px solid rgba(61, 139, 253, 0.35);
}

.kpi-label {
	font-size: 12px;
	color: var(--muted);
}

.kpi-value {
	margin-top: 3px;
	font-size: 18px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.checklist li {
	display: flex;
	gap: 8px;
	font-size: 14px;
	padding-left: 22px;
	position: relative;
}

.checklist li::before {
	position: absolute;
	left: 0;
	top: 0;
}

.checklist li.ok::before {
	content: "\2713";
	color: var(--green);
	font-weight: 700;
}

.checklist li.todo::before {
	content: "\26A0";
	color: var(--yellow);
}

.checklist li.todo {
	color: var(--text);
}

/* ===== прочее ===== */

.disclaimer {
	margin: 0;
	padding-top: 10px;
	border-top: 1px solid var(--line);
	font-size: 12px;
	color: var(--muted);
}

.foot {
	padding: 4px 6px 0;
	text-align: center;
}

.foot p {
	margin: 4px 0;
}

.mono {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 14px;
	word-break: break-all;
}

.muted {
	color: var(--muted);
}

.small {
	font-size: 12.5px;
}

.hidden {
	display: none !important;
}
