/**
 * PSM Tools — front-end styles.
 * Self-contained and scoped under .psm-tool so it does not collide with themes.
 */

.psm-tool {
	--psm-bg: #ffffff;
	--psm-surface: #f6f8fa;
	--psm-border: #e1e6eb;
	--psm-text: #1c2733;
	--psm-muted: #5c6b7a;
	--psm-accent: #ff6c30;        /* site brand colour */
	--psm-accent-dark: #d2521b;   /* hover / borders / accessible text */
	--psm-accent-soft: #ffe9e0;   /* light tint for backgrounds */
	--psm-danger: #c0392b;
	--psm-radius: 12px;
	--psm-shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 8px 24px rgba(16, 32, 48, .06);

	box-sizing: border-box;
	max-width: 1100px;
	margin: 0 auto;
	color: var(--psm-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 16px;
	line-height: 1.55;
}

.psm-tool *,
.psm-tool *::before,
.psm-tool *::after {
	box-sizing: border-box;
}

/* Intro */
.psm-tool__intro {
	margin-bottom: 1.75rem;
}
.psm-tool__title {
	margin: 0 0 .5rem;
	font-size: 1.85rem;
	font-weight: 700;
	letter-spacing: -.02em;
	color: var(--psm-text);
}
.psm-tool__lead {
	margin: 0 0 .5rem;
	max-width: 70ch;
	color: var(--psm-muted);
}
.psm-tool__credit {
	margin: 0;
	font-size: .85rem;
	font-style: italic;
	color: var(--psm-muted);
}

/* Tabs (PV mode toggle) */
.psm-tabs {
	display: inline-flex;
	gap: .25rem;
	padding: .25rem;
	margin-bottom: 1.25rem;
	background: var(--psm-surface);
	border: 1px solid var(--psm-border);
	border-radius: 999px;
}
.psm-tab {
	appearance: none;
	border: 0;
	background: transparent;
	padding: .55rem 1.1rem;
	border-radius: 999px;
	font: inherit;
	font-weight: 600;
	color: var(--psm-muted);
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
}
.psm-tab.is-active {
	background: var(--psm-accent);
	color: #fff;
}
.psm-tab:focus-visible {
	outline: 2px solid var(--psm-accent-dark);
	outline-offset: 2px;
}

/* Layout grid of input cards */
.psm-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 1rem;
	margin-bottom: 1rem;
}
.psm-card {
	background: var(--psm-bg);
	border: 1px solid var(--psm-border);
	border-radius: var(--psm-radius);
	box-shadow: var(--psm-shadow);
	padding: 1.25rem;
}
.psm-card__title {
	margin: 0 0 1rem;
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--psm-text);
	padding-bottom: .6rem;
	border-bottom: 2px solid var(--psm-accent-soft);
}

/* Fields */
.psm-field {
	margin-bottom: 1rem;
}
.psm-field:last-child {
	margin-bottom: 0;
}
.psm-field label {
	display: block;
	margin-bottom: .35rem;
	font-size: .9rem;
	font-weight: 600;
	color: var(--psm-text);
}
.psm-field input[type="number"],
.psm-field input[type="text"],
.psm-field select {
	width: 100%;
	padding: .6rem .7rem;
	font: inherit;
	color: var(--psm-text);
	background: var(--psm-bg);
	border: 1px solid var(--psm-border);
	border-radius: 8px;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.psm-field input:focus,
.psm-field select:focus {
	outline: none;
	border-color: var(--psm-accent);
	box-shadow: 0 0 0 3px var(--psm-accent-soft);
}
.psm-field--range input[type="range"] {
	width: 100%;
	accent-color: var(--psm-accent);
}
.psm-range-out {
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	color: var(--psm-accent-dark);
}

/* Info tooltip marker */
.psm-info {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	margin-left: .25rem;
	border-radius: 50%;
	background: var(--psm-accent-soft);
	color: var(--psm-accent-dark);
	font-size: .7rem;
	font-weight: 700;
	font-style: normal;
	cursor: help;
	vertical-align: middle;
}
.psm-info:focus-visible {
	outline: 2px solid var(--psm-accent);
	outline-offset: 1px;
}

/* Transformer comparison */
.psm-count {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: .5rem;
	margin-bottom: 1.1rem;
}
.psm-count__label {
	font-size: .9rem;
	font-weight: 600;
	margin-right: .25rem;
}
.psm-count__btn {
	appearance: none;
	border: 1px solid var(--psm-border);
	background: var(--psm-bg);
	padding: .45rem .9rem;
	border-radius: 8px;
	font: inherit;
	font-weight: 600;
	color: var(--psm-muted);
	cursor: pointer;
	transition: all .15s ease;
}
.psm-count__btn.is-active {
	background: var(--psm-accent);
	border-color: var(--psm-accent);
	color: #fff;
}
.psm-count__btn:focus-visible {
	outline: 2px solid var(--psm-accent-dark);
	outline-offset: 2px;
}
.psm-transformers__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 1rem;
}
.psm-transformer {
	background: var(--psm-surface);
	border: 1px solid var(--psm-border);
	border-radius: 10px;
	padding: 1rem;
}
.psm-transformer__title {
	margin: 0 0 .8rem;
	font-size: .95rem;
	font-weight: 700;
	color: var(--psm-accent-dark);
}

/* Actions */
.psm-actions {
	margin: 1.5rem 0;
	text-align: center;
}
.psm-button {
	appearance: none;
	border: 0;
	background: var(--psm-accent);
	color: #fff;
	font: inherit;
	font-weight: 700;
	font-size: 1.05rem;
	padding: .85rem 2.5rem;
	border-radius: 10px;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(255, 108, 48, .35);
	transition: background .15s ease, transform .05s ease;
}
.psm-button:hover {
	background: var(--psm-accent-dark);
}
.psm-button:active {
	transform: translateY(1px);
}
.psm-button:disabled {
	opacity: .6;
	cursor: progress;
}
.psm-button:focus-visible {
	outline: 2px solid var(--psm-accent-dark);
	outline-offset: 3px;
}

/* Results */
.psm-results {
	margin-top: 1.5rem;
	background: var(--psm-bg);
	border: 1px solid var(--psm-border);
	border-radius: var(--psm-radius);
	box-shadow: var(--psm-shadow);
	padding: 1.5rem;
}
.psm-results__title {
	margin: 0 0 1.1rem;
	font-size: 1.25rem;
	font-weight: 700;
}
.psm-results__rates {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: .75rem;
	margin-bottom: 1.25rem;
}
.psm-stat {
	display: flex;
	flex-direction: column;
	gap: .25rem;
	padding: .9rem 1rem;
	background: var(--psm-accent-soft);
	border-radius: 10px;
}
.psm-stat__label {
	font-size: .78rem;
	font-weight: 600;
	color: var(--psm-accent-dark);
	text-transform: uppercase;
	letter-spacing: .03em;
}
.psm-stat__value {
	font-size: 1.25rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: var(--psm-text);
}
.psm-results__toc {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: .75rem;
	margin-bottom: 1.25rem;
}
.psm-toc-card {
	padding: 1rem;
	border: 1px solid var(--psm-border);
	border-radius: 10px;
	text-align: center;
}
.psm-toc-card__label {
	display: block;
	font-size: .8rem;
	font-weight: 600;
	color: var(--psm-muted);
	margin-bottom: .3rem;
}
.psm-toc-card__value {
	font-size: 1.4rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: var(--psm-accent-dark);
}
.psm-results__hint {
	margin: 0 0 1rem;
	font-size: .85rem;
	color: var(--psm-muted);
}
.psm-chart-wrap {
	position: relative;
	width: 100%;
	min-height: 320px;
}

/* Error */
.psm-error {
	margin-top: 1rem;
	padding: .85rem 1rem;
	background: #fdecea;
	border: 1px solid #f5c6c0;
	border-radius: 8px;
	color: var(--psm-danger);
	font-weight: 600;
}

@media (max-width: 600px) {
	.psm-tool { font-size: 15px; }
	.psm-tool__title { font-size: 1.5rem; }
	.psm-tabs { display: flex; width: 100%; }
	.psm-tab { flex: 1; text-align: center; }
}
