/**
 * 金融计算器 — 对齐 https://lvchb6w3ol7eg.ok.kimi.link/
 */
:root {
	--primary: #e53935;
	--primary-hover: #c62828;
	--primary-light: #ffebee;
	--primary-gradient: linear-gradient(135deg, #e53935 0%, #ef5350 100%);
	--bg-body: #faf7f2;
	--bg-card: #ffffff;
	--bg-input: #f8f6f3;
	--text-primary: #2d2a26;
	--text-secondary: #6b6560;
	--text-tertiary: #a8a19a;
	--border: #edeae5;
	--border-light: #f5f2ed;
	--shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
	--radius-sm: 8px;
	--radius-lg: 16px;
	--radius-full: 9999px;
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

body {
	font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	background: var(--bg-body);
	color: var(--text-primary);
	line-height: 1.6;
	min-height: 100dvh;
	-webkit-font-smoothing: antialiased;
}

.app-container {
	max-width: 520px;
	margin: 0 auto;
	min-height: 100dvh;
	position: relative;
}

.header {
	background: linear-gradient(180deg, #faf7f2 0%, #f5efe6 100%);
	padding: calc(12px + env(safe-area-inset-top, 0)) 0 0;
	position: sticky;
	top: 0;
	z-index: 100;
}

.header-top {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 20px 16px;
	position: relative;
}

.header-back {
	position: absolute;
	left: 16px;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: background 0.2s;
	text-decoration: none;
	color: inherit;
}

.header-back:active {
	background: rgba(0, 0, 0, 0.04);
}

.header-back svg {
	width: 22px;
	height: 22px;
	stroke: var(--text-primary);
}

.header-title {
	font-size: 18px;
	font-weight: 600;
	color: var(--text-primary);
}

.header-icon {
	position: absolute;
	right: 16px;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
}

.header-icon svg {
	width: 22px;
	height: 22px;
	stroke: var(--text-secondary);
}

.tabs-bar {
	display: flex;
	padding: 0 20px;
	gap: 0;
}

.tab-btn {
	flex: 1;
	text-align: center;
	padding: 14px 0 12px;
	font-size: 15px;
	font-weight: 500;
	color: var(--text-secondary);
	cursor: pointer;
	position: relative;
	transition: all 0.25s ease;
	border: none;
	background: none;
	font-family: inherit;
}

.tab-btn.active {
	color: var(--text-primary);
	font-weight: 700;
}

.tab-btn::after {
	content: "";
	position: absolute;
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
	width: 0;
	height: 3px;
	background: var(--text-primary);
	border-radius: 2px 2px 0 0;
	transition: width 0.3s ease;
}

.tab-btn.active::after {
	width: 24px;
}

.content-area {
	padding: 16px;
	padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
}

.tab-panel {
	display: none;
}

.tab-panel.active {
	display: block;
	animation: fadeIn 0.3s ease;
}

.result-card {
	background: var(--bg-card);
	border-radius: var(--radius-lg);
	padding: 24px 20px 20px;
	box-shadow: var(--shadow);
	margin-bottom: 16px;
}

.result-label {
	font-size: 14px;
	color: var(--text-secondary);
	margin-bottom: 4px;
}

.result-value {
	font-size: 36px;
	font-weight: 900;
	color: var(--text-primary);
	letter-spacing: -1px;
	line-height: 1.2;
	word-break: break-all;
}

.result-subrow {
	display: flex;
	margin-top: 20px;
	padding-top: 16px;
	border-top: 1px solid var(--border-light);
	gap: 16px;
}

.result-subitem {
	flex: 1;
	position: relative;
	min-width: 0;
}

.result-subitem + .result-subitem::before {
	content: "";
	position: absolute;
	left: -8px;
	top: 4px;
	bottom: 4px;
	width: 1px;
	background: var(--border);
}

.result-sublabel {
	font-size: 12px;
	color: var(--text-tertiary);
	margin-bottom: 4px;
}

.result-subvalue {
	font-size: 18px;
	font-weight: 700;
	color: var(--text-primary);
	word-break: break-all;
}

.result-subitem:last-child .result-subvalue {
	text-align: right;
}

.form-section {
	background: var(--bg-card);
	border-radius: var(--radius-lg);
	padding: 20px;
	box-shadow: var(--shadow);
}

.form-group {
	margin-bottom: 20px;
}

.form-group:last-child {
	margin-bottom: 0;
}

.form-label {
	font-size: 15px;
	font-weight: 600;
	color: var(--text-primary);
	margin-bottom: 10px;
	display: block;
}

.form-input-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.form-input-prefix {
	font-size: 22px;
	font-weight: 700;
	color: var(--text-primary);
	flex-shrink: 0;
}

.form-input {
	flex: 1;
	height: 48px;
	background: transparent;
	border: none;
	border-bottom: 1.5px solid var(--border);
	font-size: 16px;
	color: var(--text-primary);
	font-family: inherit;
	transition: border-color 0.2s;
	outline: none;
	padding: 0 4px;
	min-width: 0;
}

.form-input::placeholder {
	color: var(--text-tertiary);
}

.form-input:focus {
	border-bottom-color: var(--primary);
}

.form-input-suffix {
	font-size: 16px;
	color: var(--text-secondary);
	padding-right: 4px;
	flex-shrink: 0;
}

.quick-tags {
	display: flex;
	gap: 10px;
	margin-top: 12px;
	flex-wrap: wrap;
}

.quick-tag {
	padding: 6px 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 14px;
	color: var(--text-secondary);
	background: var(--bg-card);
	cursor: pointer;
	transition: all 0.2s;
	font-family: inherit;
}

.quick-tag:active {
	transform: scale(0.95);
	border-color: var(--primary);
	color: var(--primary);
	background: var(--primary-light);
}

.select-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 0;
	border-bottom: 1px solid var(--border);
	cursor: pointer;
}

.select-label {
	font-size: 15px;
	color: var(--text-primary);
	font-weight: 500;
}

.select-value {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 15px;
	color: var(--text-secondary);
}

.select-value.active {
	color: var(--text-primary);
	font-weight: 500;
}

.select-value svg {
	width: 16px;
	height: 16px;
	stroke: var(--text-tertiary);
	stroke-width: 2;
	flex-shrink: 0;
}

.method-chips {
	display: flex;
	gap: 8px;
	margin-top: 8px;
	flex-wrap: wrap;
}

.method-chip {
	padding: 8px 16px;
	border: 1.5px solid var(--border);
	border-radius: var(--radius-full);
	font-size: 13px;
	color: var(--text-secondary);
	background: var(--bg-card);
	cursor: pointer;
	transition: all 0.2s;
	font-family: inherit;
	font-weight: 500;
}

.method-chip.active {
	border-color: var(--primary);
	background: var(--primary-light);
	color: var(--primary);
	font-weight: 600;
}

.method-chip:active {
	transform: scale(0.96);
}

.unit-toggle-inline {
	display: flex;
	gap: 4px;
	flex-shrink: 0;
}

.unit-toggle-inline button {
	padding: 4px 10px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 13px;
	color: var(--text-secondary);
	background: var(--bg-card);
	cursor: pointer;
	transition: all 0.2s;
	font-family: inherit;
}

.unit-toggle-inline button.active {
	border-color: var(--primary);
	background: var(--primary-light);
	color: var(--primary);
	font-weight: 600;
}

.loan-term-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.loan-term-row .form-input {
	flex: 1;
}

.btn-row {
	display: flex;
	gap: 12px;
	margin-top: 24px;
}

.btn-primary {
	flex: 1;
	height: 48px;
	background: var(--primary-gradient);
	border: none;
	border-radius: var(--radius-full);
	color: #fff;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
	box-shadow: 0 4px 12px rgba(229, 57, 53, 0.25);
}

.btn-primary:active {
	opacity: 0.92;
}

.btn-secondary {
	flex: 1;
	height: 48px;
	background: var(--bg-card);
	border: 1.5px solid var(--border);
	border-radius: var(--radius-full);
	color: var(--text-secondary);
	font-size: 16px;
	font-weight: 500;
	cursor: pointer;
	font-family: inherit;
}

.btn-secondary:active {
	opacity: 0.9;
}

.schedule-card {
	background: var(--bg-card);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow);
	margin-bottom: 16px;
	overflow: hidden;
}

.schedule-header {
	padding: 16px 20px;
	border-bottom: 1px solid var(--border-light);
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.schedule-title {
	font-size: 15px;
	font-weight: 600;
}

.schedule-count {
	font-size: 13px;
	color: var(--text-tertiary);
}

.schedule-body {
	max-height: 360px;
	overflow-y: auto;
}

.schedule-table {
	width: 100%;
	border-collapse: collapse;
}

.schedule-table thead th {
	position: sticky;
	top: 0;
	background: var(--bg-card);
	z-index: 1;
	padding: 10px 16px;
	font-size: 12px;
	font-weight: 600;
	color: var(--text-tertiary);
	text-align: right;
	border-bottom: 1px solid var(--border-light);
}

.schedule-table thead th:first-child {
	text-align: left;
	padding-left: 20px;
}

.schedule-table thead th:last-child {
	padding-right: 20px;
}

.schedule-table tbody td {
	padding: 10px 16px;
	font-size: 13px;
	color: var(--text-primary);
	text-align: right;
	border-bottom: 1px solid var(--border-light);
	font-variant-numeric: tabular-nums;
}

.schedule-table tbody td:first-child {
	text-align: left;
	padding-left: 20px;
	color: var(--text-secondary);
}

.schedule-table tbody td:last-child {
	padding-right: 20px;
}

.scroll-hint {
	text-align: center;
	padding: 12px;
	font-size: 12px;
	color: var(--text-tertiary);
}

.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	z-index: 1000;
	opacity: 0;
	visibility: hidden;
	transition: all 0.3s ease;
}

.modal-overlay.show {
	opacity: 1;
	visibility: visible;
}

.modal-sheet {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: #fff;
	border-radius: 24px 24px 0 0;
	z-index: 1001;
	transform: translateY(100%);
	transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
	max-height: 70vh;
	overflow-y: auto;
	padding-bottom: env(safe-area-inset-bottom, 0);
}

.modal-sheet.show {
	transform: translateY(0);
}

.modal-handle {
	width: 40px;
	height: 4px;
	background: #d1d5db;
	border-radius: 2px;
	margin: 12px auto;
}

.modal-option {
	padding: 18px 24px;
	cursor: pointer;
	border-bottom: 1px solid var(--border-light);
}

.modal-option-title {
	font-size: 16px;
	font-weight: 600;
	color: var(--text-primary);
	margin-bottom: 4px;
}

.modal-option-desc {
	font-size: 13px;
	color: var(--text-tertiary);
}

.modal-option.selected .modal-option-title {
	color: var(--primary);
}

.modal-cancel {
	padding: 16px;
	text-align: center;
	font-size: 15px;
	color: var(--text-secondary);
	cursor: pointer;
	border-top: 6px solid var(--bg-body);
	font-weight: 500;
}

.tip-section {
	margin-top: 20px;
	padding: 0 4px;
}

.tip-title {
	font-size: 13px;
	font-weight: 600;
	color: var(--text-secondary);
	margin-bottom: 6px;
}

.tip-text {
	font-size: 12px;
	color: var(--text-tertiary);
	line-height: 1.8;
}

.is-hidden {
	display: none !important;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes slideUp {
	from {
		opacity: 0;
		transform: translateY(30px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.animate-slide-up {
	animation: slideUp 0.5s ease forwards;
}

@media (min-width: 768px) {
	body {
		display: flex;
		justify-content: center;
		background: #f0ece5;
	}

	.app-container {
		max-width: 480px;
		width: 100%;
		background: var(--bg-body);
		min-height: 100dvh;
		box-shadow: 0 0 60px rgba(0, 0, 0, 0.08);
	}
}
