/* =========================================================
   CPM CarFinance Pro – Dự toán lăn bánh & trả góp
   CPM Việt Nam · cpmvietnam.net
   ========================================================= */

.cpmaq {
	--cpmaq-primary: #ec4a2c;
	--cpmaq-accent: #f7ac3b;
	--cpmaq-ink: #0f1b2d;
	--cpmaq-text: #1f2937;
	--cpmaq-muted: #6b7280;
	--cpmaq-line: #e5e7eb;
	--cpmaq-soft: #f6f7f9;
	--cpmaq-radius: 14px;
	--cpmaq-fill: 50%;
	color: var(--cpmaq-text);
	font-size: 15px;
	line-height: 1.5;
	max-width: 1180px;
	margin: 0 auto 24px;
	box-sizing: border-box;
}
.cpmaq *, .cpmaq *::before, .cpmaq *::after { box-sizing: border-box; }

.cpmaq-title {
	margin: 0 0 16px;
	font-size: 26px;
	font-weight: 800;
	color: var(--cpmaq-ink);
	text-align: center;
}

/* ---------- Tabs ---------- */
.cpmaq-tabs {
	display: flex;
	gap: 6px;
	max-width: 460px;
	margin: 0 auto 18px;
	padding: 5px;
	background: var(--cpmaq-soft);
	border: 1px solid var(--cpmaq-line);
	border-radius: 999px;
}
.cpmaq .cpmaq-tab {
	flex: 1;
	margin: 0;
	min-height: 0;
	padding: 10px 14px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--cpmaq-muted);
	font: inherit;
	font-weight: 700;
	font-size: 15px;
	line-height: 1.3;
	text-transform: none;
	letter-spacing: 0;
	cursor: pointer;
	transition: background .2s, color .2s, box-shadow .2s;
}
.cpmaq .cpmaq-tab.is-active {
	background: #fff;
	color: var(--cpmaq-primary);
	box-shadow: 0 2px 8px rgba(15, 27, 45, .12);
}

/* ---------- Bố cục ---------- */
.cpmaq-grid {
	display: grid;
	grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
	gap: 20px;
	align-items: start;
}

.cpmaq-form, .cpmaq-result {
	background: #fff;
	border: 1px solid var(--cpmaq-line);
	border-radius: var(--cpmaq-radius);
	box-shadow: 0 8px 28px rgba(15, 27, 45, .06);
}
.cpmaq-form { padding: 6px 22px 10px; margin: 0; }
.cpmaq-result { padding: 22px; position: sticky; top: 90px; }

.cpmaq-sec {
	margin: 0;
	padding: 16px 0 6px;
	border: 0;
	border-bottom: 1px dashed var(--cpmaq-line);
	min-width: 0;
}
.cpmaq-sec:last-child { border-bottom: 0; }
.cpmaq-sec legend {
	display: flex;
	align-items: center;
	gap: 10px;
	float: left;
	width: 100%;
	margin: 0 0 12px;
	padding: 0;
	font-size: 16px;
	font-weight: 800;
	color: var(--cpmaq-ink);
}
.cpmaq-sec legend + * { clear: both; }
.cpmaq-step {
	display: inline-grid;
	place-items: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--cpmaq-accent), var(--cpmaq-primary));
	color: #fff;
	font-size: 13px;
	font-weight: 800;
}

/* ---------- Ô nhập ---------- */
.cpmaq-field { display: block; margin: 0 0 14px; }
.cpmaq-field > span:first-child {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 6px;
	font-size: 13px;
	font-weight: 700;
	color: var(--cpmaq-muted);
	text-transform: none;
}
.cpmaq-field small { display: block; margin-top: 5px; font-size: 12px; color: var(--cpmaq-muted); }

.cpmaq select,
.cpmaq input[type="text"],
.cpmaq input[type="tel"],
.cpmaq input[type="number"] {
	display: block;
	width: 100%;
	height: 46px;
	margin: 0;
	padding: 0 14px;
	border: 1px solid #d6dae1;
	border-radius: 10px;
	background-color: #fff;
	color: var(--cpmaq-text);
	font: inherit;
	font-size: 15px;
	box-shadow: none;
	transition: border-color .2s, box-shadow .2s;
}
.cpmaq select { padding-right: 34px; }
.cpmaq select:disabled { background-color: var(--cpmaq-soft); color: #9ca3af; }
.cpmaq select:focus,
.cpmaq input:focus {
	outline: none;
	border-color: var(--cpmaq-primary);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--cpmaq-primary) 18%, transparent);
}

.cpmaq-money { position: relative; display: block; }
.cpmaq-money input { padding-right: 36px !important; font-weight: 700; font-size: 17px !important; }
.cpmaq-money em {
	position: absolute;
	right: 14px;
	top: 50%;
	transform: translateY(-50%);
	font-style: normal;
	font-weight: 700;
	color: var(--cpmaq-muted);
}

.cpmaq-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cpmaq-row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cpmaq-row2 > .cpmaq-field, .cpmaq-row3 > .cpmaq-field { min-width: 0; }

/* Chip chọn nhanh */
.cpmaq-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cpmaq-chip { position: relative; margin: 0; cursor: pointer; }
.cpmaq-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.cpmaq-chip span {
	display: inline-block;
	padding: 8px 14px;
	border: 1px solid #d6dae1;
	border-radius: 999px;
	background: #fff;
	font-size: 14px;
	font-weight: 600;
	color: var(--cpmaq-text);
	transition: all .15s;
	white-space: nowrap;
}
.cpmaq-chip:hover span { border-color: var(--cpmaq-primary); }
.cpmaq-chip input:checked + span {
	border-color: var(--cpmaq-primary);
	background: var(--cpmaq-primary);
	color: #fff;
}
.cpmaq-chip input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--cpmaq-primary) 25%, transparent); }

.cpmaq-check {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin: 2px 0 12px;
	font-size: 14px;
	cursor: pointer;
}
.cpmaq-check input { margin: 3px 0 0; accent-color: var(--cpmaq-primary); }

/* Thanh trượt tỷ lệ vay */
.cpmaq input[type="range"] {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 8px;
	margin: 8px 0 2px;
	padding: 0;
	border: 0;
	border-radius: 99px;
	background: linear-gradient(90deg, var(--cpmaq-primary) var(--cpmaq-fill), #e5e7eb var(--cpmaq-fill));
	box-shadow: none;
}
.cpmaq input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #fff;
	border: 3px solid var(--cpmaq-primary);
	box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
	cursor: pointer;
}
.cpmaq input[type="range"]::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	border: 3px solid var(--cpmaq-primary);
	cursor: pointer;
}
.cpmaq-pill {
	padding: 2px 10px;
	border-radius: 99px;
	background: color-mix(in srgb, var(--cpmaq-primary) 12%, #fff);
	color: var(--cpmaq-primary);
	font-size: 13px;
}

/* ---------- Kết quả ---------- */
.cpmaq-hero {
	position: relative;
	overflow: hidden;
	padding: 20px 22px;
	border-radius: 12px;
	background: linear-gradient(135deg, var(--cpmaq-ink) 0%, #1d3150 100%);
	color: #fff;
}
.cpmaq-hero::after {
	content: "";
	position: absolute;
	right: -40px;
	top: -40px;
	width: 160px;
	height: 160px;
	border-radius: 50%;
	background: radial-gradient(circle, color-mix(in srgb, var(--cpmaq-accent) 45%, transparent), transparent 70%);
}
.cpmaq-hero span { display: block; font-size: 13px; font-weight: 600; opacity: .8; text-transform: uppercase; letter-spacing: .04em; }
.cpmaq-hero strong {
	display: block;
	margin: 4px 0 2px;
	font-size: 32px;
	font-weight: 800;
	line-height: 1.2;
	color: var(--cpmaq-accent);
	font-variant-numeric: tabular-nums;
}
.cpmaq-hero small { display: block; font-size: 13px; opacity: .85; }

.cpmaq-lines { list-style: none; margin: 14px 0 0; padding: 0; }
.cpmaq-lines li {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 14px;
	margin: 0;
	padding: 10px 2px;
	border-bottom: 1px solid var(--cpmaq-line);
	font-size: 14px;
}
.cpmaq-lines li span { min-width: 0; }
.cpmaq-lines li small { display: block; font-size: 12px; color: var(--cpmaq-muted); }
.cpmaq-lines li b { white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.cpmaq-lines li.is-base b { color: var(--cpmaq-ink); }
.cpmaq-lines li.is-sub { background: var(--cpmaq-soft); padding-left: 10px; padding-right: 10px; font-weight: 700; }
.cpmaq-lines li.is-total {
	margin-top: 6px;
	padding: 12px;
	border: 0;
	border-radius: 10px;
	background: color-mix(in srgb, var(--cpmaq-primary) 10%, #fff);
	font-weight: 800;
	font-size: 15px;
}
.cpmaq-lines li.is-total b { color: var(--cpmaq-primary); font-size: 17px; }

/* Ẩn/hiện theo tab */
.cpmaq .cpmaq-panel { display: none; }
.cpmaq[data-tab="lan-banh"] .cpmaq-panel[data-panel="lan-banh"],
.cpmaq[data-tab="tra-gop"] .cpmaq-panel[data-panel="tra-gop"] { display: block; }
.cpmaq[data-mode="full"][data-tab="lan-banh"] .cpmaq-loanfields { display: none; }

/* Lịch trả nợ */
.cpmaq-sched { margin-top: 14px; }
.cpmaq-sched summary, .cpmaq-note summary {
	cursor: pointer;
	font-weight: 700;
	color: var(--cpmaq-primary);
	font-size: 14px;
	list-style-position: inside;
}
.cpmaq-tablewrap { max-height: 360px; overflow: auto; margin-top: 10px; border: 1px solid var(--cpmaq-line); border-radius: 10px; }
.cpmaq-tablewrap table { width: 100%; margin: 0; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.cpmaq-tablewrap th, .cpmaq-tablewrap td { padding: 7px 10px; border: 0; border-bottom: 1px solid var(--cpmaq-line); text-align: right; white-space: nowrap; }
.cpmaq-tablewrap th:first-child, .cpmaq-tablewrap td:first-child { text-align: center; }
.cpmaq-tablewrap thead th { position: sticky; top: 0; background: var(--cpmaq-ink); color: #fff; font-weight: 700; text-transform: none; letter-spacing: 0; }
.cpmaq-tablewrap tr.is-float td { background: #fffaf3; }
.cpmaq-tablewrap tr.is-sum td { font-weight: 800; background: var(--cpmaq-soft); }

/* ---------- Nút hành động ---------- */
.cpmaq-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.cpmaq .cpmaq-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 1 1 auto;
	min-height: 46px;
	margin: 0;
	padding: 10px 18px;
	border-radius: 10px;
	border: 1px solid transparent;
	font: inherit;
	font-weight: 800;
	font-size: 15px;
	line-height: 1.2;
	text-transform: none;
	letter-spacing: 0;
	text-decoration: none;
	cursor: pointer;
	transition: transform .15s, box-shadow .15s, background .15s;
}
.cpmaq .cpmaq-btn--main {
	flex-basis: 100%;
	background: linear-gradient(90deg, var(--cpmaq-accent), var(--cpmaq-primary));
	color: #fff;
	box-shadow: 0 6px 18px color-mix(in srgb, var(--cpmaq-primary) 35%, transparent);
}
.cpmaq .cpmaq-btn--main:hover { transform: translateY(-1px); color: #fff; }
.cpmaq .cpmaq-btn--main:disabled { opacity: .7; cursor: wait; transform: none; }
.cpmaq .cpmaq-btn--ghost { background: #fff; border-color: var(--cpmaq-primary); color: var(--cpmaq-primary); }
.cpmaq .cpmaq-btn--ghost:hover { background: color-mix(in srgb, var(--cpmaq-primary) 8%, #fff); }

.cpmaq-lead {
	margin-top: 14px;
	padding: 16px;
	border: 1px solid color-mix(in srgb, var(--cpmaq-primary) 30%, #fff);
	border-radius: 12px;
	background: color-mix(in srgb, var(--cpmaq-primary) 4%, #fff);
}
.cpmaq-lead[hidden] { display: none; }
.cpmaq-lead__title { margin: 0 0 12px; font-weight: 700; font-size: 14px; }
.cpmaq-lead .cpmaq-btn--main { width: 100%; }
.cpmaq-lead__msg { margin: 10px 0 0; font-size: 14px; font-weight: 600; }
.cpmaq-lead__msg:empty { display: none; }
.cpmaq-lead__msg.is-ok { color: #047857; }
.cpmaq-lead__msg.is-err { color: #b91c1c; }
.cpmaq .cpmaq-hp { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; opacity: 0; }

.cpmaq .cpmaq-print {
	display: block;
	width: 100%;
	margin: 12px 0 0;
	padding: 6px;
	min-height: 0;
	border: 0;
	background: none;
	color: var(--cpmaq-muted);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	text-decoration: underline;
	text-transform: none;
	letter-spacing: 0;
	cursor: pointer;
}

/* ---------- Ghi chú ---------- */
.cpmaq-note {
	margin-top: 16px;
	padding: 14px 18px;
	border-radius: 12px;
	background: var(--cpmaq-soft);
	font-size: 13px;
	color: var(--cpmaq-muted);
}
.cpmaq-note ul { margin: 10px 0 0 18px; padding: 0; }
.cpmaq-note li { margin: 0 0 6px; }
.cpmaq-credit { margin: 8px 0 0; text-align: right; font-size: 12px; color: #9ca3af; }
.cpmaq-credit a { color: inherit; text-decoration: none; font-weight: 700; }
.cpmaq-credit a:hover { color: var(--cpmaq-primary); }

/* ---------- Mobile ---------- */
@media (max-width: 849px) {
	.cpmaq-grid { grid-template-columns: 1fr; }
	.cpmaq-result { position: static; }
}
@media (max-width: 549px) {
	.cpmaq-form { padding: 4px 16px 8px; }
	.cpmaq-result { padding: 16px; }
	.cpmaq-row2 { grid-template-columns: 1fr; gap: 0; }
	.cpmaq-row3 { grid-template-columns: 1fr 1fr; }
	.cpmaq-row3 > .cpmaq-field:last-child { grid-column: 1 / -1; }
	.cpmaq-hero strong { font-size: 27px; }
	.cpmaq-title { font-size: 21px; }
	.cpmaq-tablewrap th, .cpmaq-tablewrap td { padding: 6px; font-size: 12px; }
}

/* ---------- In / lưu PDF ---------- */
@media print {
	body.cpmaq-printing * { visibility: hidden !important; }
	body.cpmaq-printing .cpmaq.is-printing,
	body.cpmaq-printing .cpmaq.is-printing * { visibility: visible !important; }
	body.cpmaq-printing .cpmaq.is-printing { position: absolute; left: 0; top: 0; width: 100%; }
	.cpmaq.is-printing .cpmaq-tabs,
	.cpmaq.is-printing .cpmaq-cta,
	.cpmaq.is-printing .cpmaq-lead,
	.cpmaq.is-printing .cpmaq-print { display: none !important; }
	.cpmaq.is-printing .cpmaq-grid { grid-template-columns: 1fr 1fr; }
	.cpmaq.is-printing .cpmaq-result { position: static; box-shadow: none; }
	.cpmaq.is-printing .cpmaq-hero { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
	.cpmaq.is-printing .cpmaq-tablewrap { max-height: none; overflow: visible; }
}
