/* MLCALC v2 — современная responsive-тема (без jQuery).
 * Эстетика Tailwind UI: Inter, серая шкала gray/slate, мягкие тени,
 * кольца фокуса; бренд-цвета — синий и красный Calculate из оригинала.
 * Легаси-контент секций (table.webpage и т.п.) стилизуется в конце файла. */

@font-face {
	font-family: 'Inter';
	src: url(fonts/InterVariable.woff2) format('woff2');
	font-weight: 100 900;
	font-style: normal;
	font-display: swap;
}

:root {
	--accent: #0a58ca;
	--accent-dark: #08459e;
	--accent-soft: #e8f0fd;
	--cta: #cf2e34;
	--cta-dark: #a92429;
	--positive: #1d9e75;
	--ink: #111827;
	--ink-soft: #6b7280;
	--line: #e5e7eb;
	--bg: #f9fafb;
	--card: #ffffff;
	--header-bg: rgba(255, 255, 255, 0.85);
	--zebra: #f9fafb;
	--row-hover: #eff6ff;
	--danger: #c2410c;
	--danger-soft: #fdeee6;
	--input-border: #d1d5db;
	--ring: 0 0 0 3px rgba(10, 88, 202, 0.16);
	--ring-cta: 0 0 0 3px rgba(207, 46, 52, 0.2);
	--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
	--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.07);
	--radius: 12px;
	--font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* тёмная тема — по системной настройке (ночью включается автоматически) */
@media (prefers-color-scheme: dark) {
	:root {
		--accent: #5a9bf6;
		--accent-dark: #3b82e0;
		--accent-soft: #16263d;
		--cta: #e8555a;
		--cta-dark: #c93f44;
		--positive: #2cb893;
		--ink: #f1f5f9;
		--ink-soft: #94a3b8;
		--line: #2c3a4f;
		--bg: #0f172a;
		--card: #1a2436;
		--header-bg: rgba(15, 23, 42, 0.85);
		--zebra: #16202f;
		--row-hover: #1c2c47;
		--danger: #ff8a5e;
		--danger-soft: #3a2419;
		--input-border: #46556b;
		--ring: 0 0 0 3px rgba(90, 155, 246, 0.25);
		--ring-cta: 0 0 0 3px rgba(232, 85, 90, 0.3);
		--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
		--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
	}
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	font-family: var(--font);
	font-size: 16px;
	line-height: 1.6;
	color: var(--ink);
	background: var(--bg);
}
a { color: var(--accent); text-decoration: none; transition: color 0.15s ease; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.25; font-weight: 600; letter-spacing: -0.025em; }
h1 { font-size: 28px; margin: 0 0 8px; }
h2 { font-size: 21px; margin: 28px 0 10px; }
h3 { font-size: 17px; margin: 22px 0 8px; }
img { max-width: 100%; height: auto; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* --- Шапка --- */
.site-header {
	background: var(--header-bg);
	-webkit-backdrop-filter: saturate(180%) blur(8px);
	backdrop-filter: saturate(180%) blur(8px);
	border-bottom: 1px solid var(--line);
	position: sticky;
	top: 0;
	z-index: 50;
}
.site-header .container {
	display: flex;
	align-items: center;
	gap: 16px;
	min-height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 600; letter-spacing: -0.025em; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.site-nav { margin-left: auto; display: flex; gap: 22px; font-size: 14px; font-weight: 500; }
.site-nav a { color: var(--ink-soft); padding: 6px 0; }
.site-nav a:hover { color: var(--ink); text-decoration: none; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; font-size: 26px; line-height: 1; color: var(--ink); cursor: pointer; padding: 8px; }

/* --- Хлебные крошки и заголовок страницы --- */
.page-head { padding-top: 22px; padding-bottom: 4px; }
.breadcrumbs { font-size: 13px; color: var(--ink-soft); margin: 0 0 6px; }
.breadcrumbs a { color: var(--ink-soft); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .sep { margin: 0 6px; color: var(--ink-soft); opacity: 0.5; }
.page-lead { color: var(--ink-soft); margin: 0; max-width: 720px; }

/* --- Сетка и карточки --- */
main.page { padding-top: 8px; padding-bottom: 40px; }
.layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 18px; }
.card {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 22px 24px;
	box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 24px; }
.card-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 14px; }

/* --- Формы --- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 5px; }
.field .control { display: flex; align-items: center; gap: 8px; }
.field .unit { color: var(--ink-soft); font-size: 14px; white-space: nowrap; }
.field .hint { font-size: 13px; color: var(--ink-soft); }
input[type='text'], input[type='email'], input[type='number'], select, textarea {
	width: 100%;
	font: inherit;
	font-size: 15px;
	color: var(--ink);
	background: var(--card);
	border: 1px solid var(--input-border);
	border-radius: 8px;
	padding: 9px 12px;
	min-height: 42px;
	box-shadow: var(--shadow-sm);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: var(--shadow-sm), var(--ring);
}
input.invalid { border-color: var(--danger); }
input.invalid:focus { box-shadow: var(--shadow-sm), var(--ring-cta); }
.field-error { color: var(--danger); font-size: 13px; margin-top: 4px; }
.radio-row { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.radio-row label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 400; color: var(--ink); }
.btn {
	display: inline-block;
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	border: 0;
	border-radius: 8px;
	padding: 11px 20px;
	cursor: pointer;
	text-align: center;
	box-shadow: var(--shadow-sm);
	transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-sm), var(--ring); }
.btn-primary { background: var(--accent); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-cta { background: var(--cta); color: #fff; width: 100%; }
.btn-cta:hover { background: var(--cta-dark); }
.btn-cta:focus-visible { box-shadow: var(--shadow-sm), var(--ring-cta); }
.btn-link { background: none; color: var(--accent); padding: 6px 0; font-weight: 500; box-shadow: none; }
.btn-link:hover { text-decoration: underline; }
.advanced { display: none; }
.advanced.open { display: block; }

/* --- Табы ипотека/кредит --- */
.calc-tabs { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.calc-tabs button {
	flex: 1;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	color: var(--ink-soft);
	background: none;
	border: 0;
	border-radius: 7px;
	padding: 8px 10px;
	cursor: pointer;
	transition: color 0.15s ease, background-color 0.15s ease;
}
.calc-tabs button:focus-visible { outline: none; box-shadow: var(--ring); }
.calc-tabs button.active { background: var(--card); color: var(--accent); box-shadow: var(--shadow-sm); }

/* --- Результаты --- */
#summary { scroll-margin-top: 72px; }
.summary-hero { text-align: center; padding: 4px 0 14px; }
.summary-hero .amount { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; color: var(--accent); line-height: 1.1; }
.summary-hero .caption { color: var(--ink-soft); font-size: 14px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 14px; }
.metric { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; transition: border-color 0.15s ease; }
.metric:hover { border-color: var(--input-border); }
.metric .v { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.metric .l { font-size: 12.5px; color: var(--ink-soft); }
.facts { width: 100%; border-collapse: collapse; font-size: 14.5px; margin-top: 6px; }
.facts td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.facts td:last-child { text-align: right; font-weight: 600; white-space: nowrap; }
.facts tr:last-child td { border-bottom: 0; }

/* --- Разбивка платежа (стековый бар) --- */
.pay-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin-top: 16px; }
.pay-bar i { display: block; height: 100%; }
.pay-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-soft); margin-top: 8px; }
.pay-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }

/* --- Таблица амортизации --- */
.table-wrap { overflow-x: auto; }
table.schedule { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.schedule th {
	position: sticky;
	top: 0;
	text-align: right;
	font-size: 11.5px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	background: var(--bg);
	color: var(--ink-soft);
	padding: 9px 10px;
	border-bottom: 1px solid var(--line);
	white-space: nowrap;
}
table.schedule th:first-child, table.schedule td:first-child { text-align: left; }
table.schedule td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.schedule tr:nth-child(even) td { background: var(--zebra); }
table.schedule tr:hover td { background: var(--row-hover); }
table.schedule tr.subtotal td { font-weight: 600; background: var(--accent-soft); }
table.schedule tr.totals td { font-weight: 700; border-top: 2px solid var(--accent); background: none; }

/* --- Ставки --- */
.states-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; font-size: 14.5px; }
.prose { max-width: 100%; }
.prose p { margin: 0 0 12px; }

/* --- График кредита --- */
.calc-chart { width: 100%; height: 130px; margin-top: 6px; display: block; }
.chart-x { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.summary-hero .amount, .metric .v, .facts td:last-child { font-variant-numeric: tabular-nums; }

/* --- Живые ставки --- */
.rate-week { font-weight: 400; font-size: 13px; color: var(--ink-soft); letter-spacing: 0; }
.rate-chart { width: 100%; height: 64px; margin-top: 14px; display: block; }
.rate-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-soft); margin: 6px 0 4px; }
.rate-legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.delta { font-size: 13px; font-weight: 600; vertical-align: 2px; }
.delta.up { color: var(--danger); }
.delta.down { color: var(--positive); }
.delta.flat { color: var(--ink-soft); }
.rate-source { font-size: 12.5px; color: var(--ink-soft); margin: 12px 0 0; }

/* --- Реклама --- */
.ad-slot { margin: 20px 0; text-align: center; }
.ad-slot ins { margin: 0 auto; }

/* --- Подвал --- */
.site-footer { border-top: 1px solid var(--line); background: var(--card); margin-top: 40px; padding: 26px 0; font-size: 14px; color: var(--ink-soft); }
.site-footer .links { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 12px; font-weight: 500; }
.site-footer a { color: var(--ink-soft); }
.site-footer a:hover { color: var(--accent); }

/* --- Сообщения --- */
.alert { border-radius: 8px; padding: 12px 16px; font-size: 14.5px; margin-bottom: 14px; }
.alert-success { background: var(--accent-soft); color: var(--accent-dark); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }

/* --- SEO-текст --- */
.seo-text { color: var(--ink-soft); font-size: 14.5px; line-height: 1.7; margin-top: 28px; }

/* --- Появление пересчитанных блоков --- */
@keyframes swap-in {
	from { opacity: 0; transform: translateY(4px); }
	to { opacity: 1; transform: none; }
}
.swap { animation: swap-in 0.25s ease; }
@media (prefers-reduced-motion: reduce) {
	.swap { animation: none; }
	a, .btn, input, select, textarea, .metric, .calc-tabs button { transition: none; }
}

/* --- Легаси-контент (страницы виджетов, downloads, terms и т.п.) --- */
.legacy table.webpage { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.legacy table.webpage > tbody > tr > td { padding: 18px 24px; }
.legacy table { border-collapse: collapse; max-width: 100%; }
.legacy .big { font-size: 24px; font-weight: 600; letter-spacing: -0.025em; }
.legacy .medium { font-size: 18px; font-weight: 600; }
.legacy .small { font-size: 13px; color: var(--ink-soft); }
.legacy textarea, .legacy input[type='text'] { width: auto; max-width: 100%; }
.legacy .separator { display: none; }
.legacy .action-button, .legacy input[type='submit'], .legacy input[type='button'] {
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	background: var(--accent);
	color: #fff;
	border: 0;
	border-radius: 8px;
	padding: 9px 16px;
	cursor: pointer;
	box-shadow: var(--shadow-sm);
	transition: background-color 0.15s ease;
}
.legacy .action-button:hover, .legacy input[type='submit']:hover, .legacy input[type='button']:hover { background: var(--accent-dark); }
.legacy pre, .legacy code, .legacy textarea.code { font-size: 13px; }

/* --- Адаптив --- */
@media (max-width: 880px) {
	/* minmax(0,1fr): иначе min-width:auto широкого контента (таблица
	   амортизации) распирает колонку шире вьюпорта */
	.layout { grid-template-columns: minmax(0, 1fr); }
	h1 { font-size: 23px; }
	.summary-hero .amount { font-size: 32px; }
	.site-nav {
		display: none;
		position: absolute;
		top: 60px;
		left: 0;
		right: 0;
		background: var(--card);
		border-bottom: 1px solid var(--line);
		box-shadow: var(--shadow-md);
		flex-direction: column;
		gap: 0;
		padding: 8px 16px 14px;
	}
	.site-nav.open { display: flex; }
	.site-nav a { padding: 10px 0; border-bottom: 1px solid var(--bg); }
	.nav-toggle { display: block; }
	.card { padding: 18px 16px; }
	.legacy table.webpage > tbody > tr > td { padding: 14px 14px; }
}
