@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700;800&family=Inter:wght@400;500;600&display=swap');

.borrowcalc-widget {
	--bc-bg: #0a1826;
	--bc-card: #0d2036;
	--bc-panel: #0f2740;
	--bc-panel-border: #1c3a52;
	--bc-navy-pill: #122a44;
	--bc-teal: #2dd4bf;
	--bc-teal-strong: #14b8a6;
	--bc-teal-dim: #7fd9cd;
	--bc-ink: #eaf6f6;
	--bc-muted: #8fa6b8;
	--bc-white: #ffffff;
	--bc-amber: #ffb98a;
	--bc-red: #ff8a8a;
	--bc-font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
	--bc-font-body: 'Inter', 'Segoe UI', sans-serif;
	--bc-font-mono: 'Space Grotesk', 'Courier New', monospace;

	display: flex;
	justify-content: center;
	background: var(--bc-bg);
	padding: 24px 16px;
	font-family: var(--bc-font-body);
	color: var(--bc-ink);
}
.borrowcalc-widget *,
.borrowcalc-widget *::before,
.borrowcalc-widget *::after {
	box-sizing: border-box;
}
.borrowcalc-widget button {
	font: inherit;
}

.borrowcalc-shell {
	width: 100%;
	max-width: 1040px;
	background: var(--bc-card);
	border: 1px solid var(--bc-panel-border);
	border-radius: 20px;
	overflow: hidden;
	box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}

/* ---------- Banner ---------- */
.borrowcalc-banner {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 22px 28px;
	background: linear-gradient(120deg, #0d3b3a, #0d2036 65%);
	border-bottom: 1px solid var(--bc-panel-border);
}
.borrowcalc-icon-badge {
	flex-shrink: 0;
	width: 48px;
	height: 48px;
	border-radius: 14px;
	background: linear-gradient(135deg, var(--bc-teal-strong), var(--bc-teal));
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: var(--bc-font-display);
	font-weight: 800;
	font-size: 1.4rem;
	color: #06231f;
}
.borrowcalc-header-title {
	font-family: var(--bc-font-display);
	font-weight: 800;
	font-size: 1.4rem;
	color: var(--bc-white);
	margin: 0;
}
.borrowcalc-header-tagline {
	font-size: 0.82rem;
	color: var(--bc-teal-dim);
	margin-top: 2px;
}

/* ---------- Body layout ---------- */
.borrowcalc-body {
	display: grid;
	grid-template-columns: 1.55fr 1fr;
	gap: 0;
}
.borrowcalc-main {
	padding: 26px 28px;
	border-right: 1px solid var(--bc-panel-border);
}
.borrowcalc-side {
	padding: 26px 24px;
	background: var(--bc-panel);
}

/* ---------- Section headings ---------- */
.borrowcalc-section-label {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--bc-teal-dim);
	margin-bottom: 10px;
}
.borrowcalc-main .borrowcalc-section-label:not(:first-child) {
	margin-top: 22px;
}

/* ---------- Pills ---------- */
.borrowcalc-pill-row {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	margin-bottom: 4px;
}
.borrowcalc-pill-btn {
	appearance: none;
	border: 1px solid var(--bc-panel-border);
	background: var(--bc-navy-pill);
	color: var(--bc-teal-dim);
	font-weight: 600;
	font-size: 0.85rem;
	padding: 10px 18px;
	border-radius: 999px;
	cursor: pointer;
	transition: all 0.15s ease;
}
.borrowcalc-pill-btn.is-active {
	background: var(--bc-teal-strong);
	border-color: var(--bc-teal-strong);
	color: #06231f;
}

/* ---------- Fields ---------- */
.borrowcalc-field-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin-bottom: 4px;
}
.borrowcalc-field label {
	display: block;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--bc-muted);
	margin-bottom: 6px;
}
.borrowcalc-field input,
.borrowcalc-field select {
	width: 100%;
	border: none;
	border-radius: 10px;
	padding: 12px 13px;
	font-family: var(--bc-font-mono);
	font-size: 0.95rem;
	background: var(--bc-white);
	color: #10233a;
	outline: none;
}
.borrowcalc-field input:focus,
.borrowcalc-field select:focus {
	box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.45);
}
.borrowcalc-field-full { grid-column: 1 / -1; }

.borrowcalc-checkbox-row {
	display: flex;
	align-items: center;
	gap: 9px;
	margin: 10px 0;
	font-size: 0.88rem;
	color: var(--bc-ink);
}
.borrowcalc-checkbox-row input[type="checkbox"] {
	width: 17px;
	height: 17px;
	accent-color: var(--bc-teal-strong);
	cursor: pointer;
}
.borrowcalc-checkbox-row label { cursor: pointer; }
.borrowcalc-sub-fields {
	display: none;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin: 8px 0 12px;
	padding: 12px;
	background: var(--bc-navy-pill);
	border-radius: 10px;
}
.borrowcalc-sub-fields.is-visible { display: grid; }

.borrowcalc-calc-btn {
	appearance: none;
	width: 100%;
	border: none;
	border-radius: 12px;
	padding: 15px;
	background: linear-gradient(135deg, var(--bc-teal-strong), var(--bc-teal));
	color: #06231f;
	font-family: var(--bc-font-display);
	font-weight: 800;
	font-size: 1.05rem;
	cursor: pointer;
	margin: 18px 0 18px;
	transition: transform 0.1s ease;
}
.borrowcalc-calc-btn:hover { transform: translateY(-1px); }
.borrowcalc-calc-btn:active { transform: translateY(0); }

.borrowcalc-examples-row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 22px;
}
.borrowcalc-example-chip {
	appearance: none;
	border: 1px solid var(--bc-panel-border);
	background: var(--bc-navy-pill);
	color: var(--bc-teal-dim);
	font-size: 0.8rem;
	padding: 7px 13px;
	border-radius: 999px;
	cursor: pointer;
	transition: all 0.15s ease;
}
.borrowcalc-example-chip:hover { border-color: var(--bc-teal); color: var(--bc-white); }

/* ---------- Result panel ---------- */
.borrowcalc-result-panel {
	background: var(--bc-panel);
	border: 1px solid var(--bc-panel-border);
	border-radius: 16px;
	padding: 20px 20px 18px;
}
.borrowcalc-result-headline { text-align: center; margin-bottom: 16px; }
.borrowcalc-result-label {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--bc-muted);
	margin-bottom: 8px;
}
.borrowcalc-result-value {
	font-family: var(--bc-font-display);
	font-weight: 800;
	font-size: 2.1rem;
	color: var(--bc-teal);
}
.borrowcalc-dti-note {
	font-size: 0.8rem;
	color: var(--bc-amber);
	margin-top: 8px;
}
.borrowcalc-dti-note.is-ok { color: var(--bc-teal-dim); }

.borrowcalc-stat-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 10px;
	margin-bottom: 18px;
}
.borrowcalc-stat-box {
	background: var(--bc-navy-pill);
	border: 1px solid var(--bc-panel-border);
	border-radius: 10px;
	padding: 10px 8px;
	text-align: center;
}
.borrowcalc-stat-label {
	font-size: 0.6rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--bc-muted);
	margin-bottom: 5px;
}
.borrowcalc-stat-value {
	font-family: var(--bc-font-mono);
	font-weight: 700;
	font-size: 0.92rem;
	color: var(--bc-ink);
}

.borrowcalc-sensitivity-row {
	display: flex;
	gap: 8px;
	margin-bottom: 18px;
}
.borrowcalc-sensitivity-box {
	flex: 1;
	text-align: center;
	padding: 10px 6px;
	border-radius: 10px;
	background: var(--bc-navy-pill);
	border: 1px solid var(--bc-panel-border);
}
.borrowcalc-sensitivity-box.is-current { border-color: var(--bc-teal); background: rgba(45, 212, 191, 0.08); }
.borrowcalc-sensitivity-label { font-size: 0.65rem; color: var(--bc-muted); margin-bottom: 4px; }
.borrowcalc-sensitivity-value { font-family: var(--bc-font-mono); font-weight: 700; font-size: 0.85rem; color: var(--bc-ink); }
.borrowcalc-sensitivity-box.is-current .borrowcalc-sensitivity-value { color: var(--bc-teal); }

.borrowcalc-formula-block { margin-bottom: 12px; }
.borrowcalc-formula-title { font-size: 0.76rem; font-weight: 600; color: var(--bc-teal-dim); margin-bottom: 8px; }
.borrowcalc-formula-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.borrowcalc-formula-box {
	flex: 1; min-width: 90px;
	background: var(--bc-navy-pill); border: 1px solid var(--bc-panel-border);
	border-radius: 10px; padding: 8px 10px;
}
.borrowcalc-formula-box.is-result { border-color: var(--bc-teal); background: rgba(45, 212, 191, 0.08); }
.borrowcalc-formula-box .borrowcalc-fb-label { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--bc-muted); margin-bottom: 4px; }
.borrowcalc-formula-box .borrowcalc-fb-value { font-family: var(--bc-font-mono); font-weight: 700; font-size: 0.88rem; color: var(--bc-ink); }
.borrowcalc-formula-box.is-result .borrowcalc-fb-value { color: var(--bc-teal); }
.borrowcalc-formula-op { font-family: var(--bc-font-display); font-weight: 700; font-size: 1rem; color: var(--bc-muted); }

.borrowcalc-explain {
	background: rgba(45, 212, 191, 0.07);
	border: 1px solid var(--bc-panel-border);
	border-radius: 10px;
	padding: 13px 15px;
	font-size: 0.82rem;
	color: var(--bc-teal-dim);
	line-height: 1.6;
	margin-top: 16px;
}
.borrowcalc-explain strong { color: var(--bc-white); }
.borrowcalc-explain ul { margin: 8px 0 0; padding-left: 18px; }
.borrowcalc-explain li { margin-bottom: 4px; }

.borrowcalc-export-result-row {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	margin-top: 16px;
}
.borrowcalc-export-result-row .borrowcalc-mini-btn { flex: 1; min-width: 90px; }

.borrowcalc-error-box {
	background: rgba(255, 138, 76, 0.12);
	border: 1px solid rgba(255, 138, 76, 0.4);
	color: var(--bc-amber);
	border-radius: 10px;
	padding: 12px 14px;
	font-size: 0.88rem;
}

/* ---------- History side panel ---------- */
.borrowcalc-history-header {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 14px;
}
.borrowcalc-history-title {
	font-family: var(--bc-font-display);
	font-weight: 800;
	font-size: 1.1rem;
	color: var(--bc-white);
}
.borrowcalc-history-count {
	background: var(--bc-teal-strong);
	color: #06231f;
	font-weight: 700;
	font-size: 0.72rem;
	min-width: 20px;
	height: 20px;
	border-radius: 999px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0 6px;
}

.borrowcalc-side input[type="text"],
.borrowcalc-side select {
	width: 100%;
	border: none;
	border-radius: 10px;
	padding: 11px 13px;
	font-size: 0.85rem;
	background: var(--bc-white);
	color: #10233a;
	outline: none;
	margin-bottom: 10px;
}
.borrowcalc-side input[type="text"]:focus,
.borrowcalc-side select:focus {
	box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.45);
}
.borrowcalc-side select {
	appearance: none;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2310233a' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 14px;
	padding-right: 34px;
	cursor: pointer;
}

.borrowcalc-history-list {
	max-height: 300px;
	overflow-y: auto;
	margin-bottom: 20px;
}
.borrowcalc-history-empty {
	text-align: center;
	color: var(--bc-muted);
	font-size: 0.85rem;
	font-style: italic;
	padding: 24px 8px;
}
.borrowcalc-history-item {
	background: var(--bc-navy-pill);
	border: 1px solid var(--bc-panel-border);
	border-radius: 10px;
	padding: 10px 12px;
	margin-bottom: 8px;
	font-size: 0.8rem;
	cursor: pointer;
	transition: border-color 0.15s ease;
}
.borrowcalc-history-item:hover { border-color: var(--bc-teal); }
.borrowcalc-history-item-top {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: 4px;
}
.borrowcalc-history-item-amount {
	font-family: var(--bc-font-mono);
	font-weight: 700;
	color: var(--bc-teal);
	font-size: 0.92rem;
}
.borrowcalc-history-item-time {
	color: var(--bc-muted);
	font-size: 0.68rem;
}
.borrowcalc-history-item-detail {
	color: var(--bc-muted);
	font-size: 0.74rem;
}

.borrowcalc-export-label {
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--bc-muted);
	margin-bottom: 10px;
}
.borrowcalc-export-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin-bottom: 10px;
}
.borrowcalc-mini-btn {
	appearance: none;
	border: 1px solid var(--bc-panel-border);
	background: var(--bc-navy-pill);
	color: var(--bc-ink);
	font-weight: 600;
	font-size: 0.82rem;
	padding: 11px 8px;
	border-radius: 10px;
	cursor: pointer;
	transition: all 0.15s ease;
}
.borrowcalc-mini-btn:hover:not(:disabled) { border-color: var(--bc-teal); color: var(--bc-teal); }
.borrowcalc-mini-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.borrowcalc-clear-btn {
	appearance: none;
	width: 100%;
	border: 1px solid rgba(255, 138, 138, 0.4);
	background: transparent;
	color: var(--bc-red);
	font-weight: 600;
	font-size: 0.85rem;
	padding: 11px 8px;
	border-radius: 10px;
	cursor: pointer;
	transition: all 0.15s ease;
}
.borrowcalc-clear-btn:hover:not(:disabled) { background: rgba(255, 138, 138, 0.1); }
.borrowcalc-clear-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
	.borrowcalc-body { grid-template-columns: 1fr; }
	.borrowcalc-main { border-right: none; border-bottom: 1px solid var(--bc-panel-border); }
	.borrowcalc-stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
	.borrowcalc-main, .borrowcalc-side { padding: 20px 18px; }
	.borrowcalc-field-grid { grid-template-columns: 1fr; }
	.borrowcalc-export-grid { grid-template-columns: 1fr; }
	.borrowcalc-sensitivity-row { flex-direction: column; }
	.borrowcalc-banner { padding: 18px 20px; }
}
