:root {
	--ink: #1b1b1a;
	--muted: #5a5a55;
	--paper: #f7f1e5;
	--accent: #d86b3c;
	--accent-dark: #a64a25;
	--panel: #fffdf7;
	--shadow: rgba(0, 0, 0, 0.12);
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	color: var(--ink);
	background:
		radial-gradient(900px 600px at 5% -10%, rgba(216, 107, 60, 0.18), transparent 55%),
		radial-gradient(700px 500px at 95% -15%, rgba(37, 99, 71, 0.16), transparent 60%),
		linear-gradient(180deg, #f4e7d4, #efe3d0 45%, #f7f1e5 100%);
	font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
	min-height: 100vh;
}

.page {
	max-width: 1100px;
	margin: 0 auto;
	padding: 20px;
}

header {
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin-bottom: 32px;
}

h1 {
	font-size: clamp(2rem, 3vw, 2.8rem);
	letter-spacing: 0.02em;
	margin: 0;
}

.subtitle {
	color: var(--muted);
	font-size: 1.05rem;
	max-width: 90ch;
	width: 85%;
	margin-right: 0;
	line-height: 1.5;
}

.grid {
	display: grid;
	gap: 24px;
	grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
}

.panel {
	background: var(--panel);
	border-radius: 18px;
	box-shadow: 0 22px 45px -35px var(--shadow);
	padding: 24px;
	border: 1px solid rgba(0, 0, 0, 0.06);
}

.panel--reports {
	overflow: hidden;
	max-height: 2000px;
	opacity: 1;
	transform: translateY(0);
	transition: max-height 0.35s ease, opacity 0.35s ease, transform 0.35s ease, padding 0.35s ease, border-color 0.35s ease;
}

.panel--reports.is-hidden {
	max-height: 0;
	opacity: 0;
	transform: translateY(12px);
	padding-top: 0;
	padding-bottom: 0;
	border-color: transparent;
}

.tabs {
	display: flex;
	gap: 8px;
	margin-bottom: 18px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.tab-button {
	border: 1px solid rgba(0, 0, 0, 0.14);
	background: transparent;
	color: var(--muted);
	padding: 10px 16px 9px;
	border-radius: 0;
	font-size: 0.95rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
	border-bottom-color: transparent;
}

.tab-button:hover {
	color: var(--ink);
}

.tab-button.is-active {
	background: #fff7ec;
	color: var(--ink);
	border-color: rgba(0, 0, 0, 0.2);
	border-bottom-color: var(--panel);
	box-shadow: inset 0 -3px 0 0 var(--accent);
}

.tab-panel {
	display: none;
}

.tab-panel.is-active {
	display: block;
}

.radio-group {
	display: grid;
	gap: 12px;
	margin: 0 0 18px;
	border: none;
	padding: 0;
}

.radio-option {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 600;
	color: var(--ink);
}

.entry-panel {
	margin-bottom: 18px;
}

label {
	display: block;
	font-weight: 600;
	margin-bottom: 12px;
	letter-spacing: 0.01em;
}

textarea {
	width: 100%;
	min-height: 360px;
	resize: vertical;
	padding: 16px;
	border-radius: 12px;
	border: 1px solid rgba(0, 0, 0, 0.15);
	font-family: "Courier New", Courier, monospace;
	font-size: 0.95rem;
	background: #fff;
	color: #1b1b1a;
}

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

.input-row input,
.input-row select {
	width: 140px;
	padding: 10px 12px;
	border-radius: 10px;
	border: 1px solid rgba(0, 0, 0, 0.15);
	font-size: 1rem;
	font-family: "Courier New", Courier, monospace;
}

.select-standard {
	font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif !important;
}

.select-standard option {
	font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif !important;
}

.earnings-source-select {
	width: 360px !important;
	max-width: none;
}

/* Make selects inside the assumptions table half as wide as the default */
.assumptions-table .input-row select {
    width: 70px !important;
}

/* If an unusually wide select appears inside the assumptions table, reduce by half as well */
.assumptions-table .input-row select.earnings-source-select {
	width: 216px !important; /* 20% wider than 180px */
}

.salary-input {
	width: 180px;
}

.input-prefix {
	color: var(--muted);
	font-weight: 600;
}

.input-suffix {
	color: var(--muted);
	font-weight: 600;
}

.file-input {
	width: 100%;
	padding: 12px 14px;
	border-radius: 12px;
	border: 1px solid rgba(0, 0, 0, 0.15);
	background: #fff;
	font-family: "Courier New", Courier, monospace;
}

/* Import instructions shown next to the XML upload input */
.import-instructions {
	margin-top: 12px;
	background-color: #f9f9f9;
	padding: 14px;
	border-left: 5px solid #2980b9;
	border-radius: 6px;
	color: var(--muted);
}
.import-instructions h2 {
	color: #2980b9;
	margin: 0 0 8px 0;
	font-size: 1rem;
}
.import-instructions .step-box {
	background-color: transparent;
	padding: 10px 0;
	margin: 10px 0;
}
.import-instructions .step-box h3 {
	margin: 6px 0;
	font-size: 0.98rem;
}
.import-instructions .warning {
	background-color: #fff3cd;
	padding: 12px;
	border: 1px solid #ffeeba;
	border-radius: 4px;
	margin-top: 10px;
	color: var(--ink);
}
.import-instructions code {
	background: #eee;
	padding: 2px 6px;
	border-radius: 3px;
}

/* Small helper above the file input */
.import-help {
	display: block;
	margin-top: 12px;
	margin-bottom: 8px;
	color: var(--muted);
	font-size: 0.98rem;
	line-height: 1.4;
}

/* Ensure this helper label is not bold (overrides other label styles) */
.import-help {
	font-weight: 400 !important;
}

/* Stack multiple stats in one report column */
.stat-column {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}
.stat-subtitle {
	margin: 0.25rem 0 0;
	font-size: 0.9rem;
	color: var(--muted);
	font-weight: 600;
}

.actions {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-top: 16px;
}

button {
	background: var(--accent);
	color: white;
	border: none;
	border-radius: 999px;
	padding: 12px 22px;
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 14px 24px -18px rgba(216, 107, 60, 0.8);
	transition: transform 0.2s ease, background 0.2s ease;
}

button:hover {
	background: var(--accent-dark);
	transform: translateY(-1px);
}

.hint {
	color: var(--muted);
	font-size: 0.95rem;
}

.results {
	display: grid;
	gap: 16px;
	/* Two-row layout: monthly row above, then a single row of stats beneath */
	grid-template-rows: auto 1fr;
	align-items: stretch;
}

.table-wrap {
	overflow-x: auto;
}

.assumptions-table {
	width: 100%;
	border-collapse: collapse;
}

.assumptions-table th,
.assumptions-table td {
	text-align: left;
	padding: 8px 8px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	vertical-align: middle;
}

/* Remove the bottom border for specially marked rows (e.g. method selector) */
.assumptions-table tr.no-border-bottom th,
.assumptions-table tr.no-border-bottom td {
	border-bottom: none;
}

/* Divider above import instructions */
.import-instructions {
    border-top: 1px solid rgba(0,0,0,0.08);
    padding-top: 12px;
    margin-top: 12px;
}

/* Put a divider under the short method/import explanation in the import entry panel */
.entry-panel#entry-import .import-help:last-of-type,
.entry-panel#entry-estimate .import-help:last-of-type {
	display: block;
	padding-bottom: 12px;
	margin-bottom: 12px;
	border-bottom: 1px solid rgba(0,0,0,0.08);
}

.assumptions-table th {
	width: 20%;
	color: var(--muted);
	font-size: 0.95rem;
	font-weight: 600;
}

.assumptions-table label {
	margin: 0;
}

.assumptions-table td {
	padding-left: 0;
}

.earnings-table {
	width: 100%;
	border-collapse: collapse;
	min-width: 540px;
}

.earnings-table th,
.earnings-table td {
	text-align: left;
	padding: 10px 12px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	font-size: 0.95rem;
}

.earnings-table th {
	color: var(--muted);
	font-size: 0.8rem;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.table-input {
	width: 100%;
	padding: 8px 10px;
	border-radius: 8px;
	border: 1px solid rgba(0, 0, 0, 0.12);
	font-size: 0.95rem;
	font-family: "Courier New", Courier, monospace;
	background: #fff;
}

.table-input--readonly {
	background: #f0eee7;
	color: var(--muted);
	border-color: rgba(0, 0, 0, 0.08);
	user-select: none;
	pointer-events: none;
}

.results--row {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Align small stat blocks in the Earnings Record tab in a single row */
.results--row.earnings-record-stats {
	display: flex;
	gap: 12px;
	align-items: center; /* vertically align content */
}

/* Ensure the two stat blocks share the row and don't inherit global grid placements */
.results--row.earnings-record-stats .stat {
	/* reduce to roughly half the previous width (approx 16%) */
	flex: 0 0 16%;
	max-width: 16%;
	min-width: 120px; /* keep readable on narrow viewports */
}
.results--row.earnings-record-stats .stat--pia {
	/* undo global grid-placement rules that apply elsewhere */
	grid-column: auto !important;
	grid-row: auto !important;
}

@media (max-width: 900px) {
	.results--row.earnings-record-stats .stat {
		flex: 1 1 0;
		max-width: none;
		min-width: 0;
	}
}

/* Explicit placements for a 2-row results grid */
.results--row .stat-column {
	grid-column: 1 / 2;
	grid-row: 2 / 3; /* bottom row */
}
.results--row .stat--savings {
	grid-column: 2 / 3;
	grid-row: 2 / 3; /* move Savings to bottom row */
}
.results--row .stat--investment {
	grid-column: 3 / 4;
	grid-row: 2 / 3;
}
.results--row .stat--pia {
	grid-column: 2 / 3;
	grid-row: 2 / 3;
}

.results--row .stat--startyear {
	grid-column: 1 / 2;
	grid-row: 1 / 2;
}

.results--row .stat--monthly {
	grid-column: 2 / 3;
	grid-row: 1 / 2;
}

.results--row .stat--annual {
	grid-column: 3 / 4;
	grid-row: 1 / 2;
}

.stat {
	padding: 16px;
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.7);
	border: 1px solid rgba(0, 0, 0, 0.06);
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	height: 100%;
}

.stat h3 {
	margin: 0 0 6px;
	font-size: 0.95rem;
	color: var(--muted);
	letter-spacing: 0.03em;
	text-transform: uppercase;
}

.stat p {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 600;
}

/* Investment stat tooltip: larger text and shown when hovering/focusing the whole stat cell */
.stat.stat--investment,
.stat.stat--savings,
.stat.stat--npv,
.stat.stat--startyear,
.stat.stat--monthly,
.stat.stat--annual {
	position: relative;
}
.stat.stat--investment .stat-tooltip,
.stat.stat--savings .stat-tooltip,
.stat.stat--npv .stat-tooltip,
.stat.stat--startyear .stat-tooltip,
.stat.stat--monthly .stat-tooltip,
.stat.stat--annual .stat-tooltip {
	display: none;
	position: absolute;
	left: 8px;
	top: 100%;
	transform: none;
	margin-top: -10px; /* moved up an additional 4px */
	background: rgba(0,0,0,0.85);
	color: #fff;
	border: none;
	box-shadow: 0 6px 18px rgba(0,0,0,0.08);
	padding: 8px 10px;
	border-radius: 6px;
	z-index: 30;
	width: calc(100% - 16px);
	box-sizing: border-box;
	font-size: calc(1em - 2px); /* reduce font size by ~2px */
	line-height: 1.2;
	white-space: normal;
}
.stat.stat--investment:hover .stat-tooltip,
.stat.stat--investment:focus-within .stat-tooltip,
.stat.stat--savings:hover .stat-tooltip,
.stat.stat--savings:focus-within .stat-tooltip,
.stat.stat--npv:hover .stat-tooltip,
.stat.stat--npv:focus-within .stat-tooltip,
.stat.stat--startyear:hover .stat-tooltip,
.stat.stat--startyear:focus-within .stat-tooltip,
.stat.stat--monthly:hover .stat-tooltip,
.stat.stat--monthly:focus-within .stat-tooltip,
.stat.stat--annual:hover .stat-tooltip,
.stat.stat--annual:focus-within .stat-tooltip {
	display: block;
}

.status {
	font-size: 0.95rem;
	color: var(--muted);
	min-height: 1.2em;
}

@media (max-width: 900px) {
	.grid {
		grid-template-columns: 1fr;
	}

	.results--row {
		grid-template-columns: 1fr;
	}

	textarea {
		min-height: 280px;
	}
}
