/* Tool UI shared by every tool. Uses the theme's colour tokens, with
   fallbacks so tools still look right under another theme. */

/* Tool widgets: wrap each tool's markup in .tool */
.tool {
	background: var(--surface, #fff);
	border: 1px solid var(--border, #e1e6ee);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 1.5rem;
	margin-block: 1.5rem;
}

.tool__fields {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 1rem;
}

.tool label {
	display: block;
	font-weight: 600;
	font-size: 0.9rem;
	margin-block-end: 0.3rem;
}

.tool input,
.tool select {
	width: 100%;
	padding: 0.65rem 0.75rem;
	border: 1px solid var(--border, #e1e6ee);
	border-radius: var(--radius-sm);
	background: var(--bg, #f5f7fa);
	color: var(--text, #0f1f3a);
	font: inherit;
}

.tool__result {
	margin-block-start: 1.25rem;
	padding: 1rem 1.25rem;
	background: var(--brand-soft, #e6f4f2);
	border-radius: var(--radius-sm);
}

.tool__result strong {
	display: block;
	font-size: 1.6rem;
	color: var(--brand-strong, #0b5e57);
}

.tool__note {
	font-size: 0.85rem;
	color: var(--muted, #56617a);
}

/* Tool action bar: Sample, Clear, Copy, Download */
.tool__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-block: 1rem;
}

.tool__actions button {
	padding: 0.55rem 1rem;
	border: 1px solid var(--border, #e1e6ee);
	border-radius: var(--radius-sm);
	background: var(--surface, #fff);
	color: var(--text, #0f1f3a);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.tool__actions button:hover {
	border-color: var(--brand, #0f766e);
}

.tool__actions .is-primary {
	background: var(--brand, #0f766e);
	border-color: var(--brand, #0f766e);
	color: var(--on-brand, #fff);
}

.tool textarea {
	width: 100%;
	min-height: 240px;
	padding: 0.8rem;
	border: 1px solid var(--border, #e1e6ee);
	border-radius: var(--radius-sm);
	background: var(--bg, #f5f7fa);
	color: var(--text, #0f1f3a);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.9rem;
}

/* Press feedback and a progress bar for tools that run for a while. */
.tool button {
	transition: transform 0.08s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.tool button:active {
	transform: scale(0.97);
}

.tool__progress {
	height: 6px;
	margin-block: 1rem;
	border-radius: 999px;
	background: var(--border, #e1e6ee);
	overflow: hidden;
}

.tool__progress > span {
	display: block;
	height: 100%;
	width: var(--progress, 0%);
	background: var(--brand, #0f766e);
	transition: width 0.2s linear;
}

.tool.is-running .tool__progress > span {
	animation: bankersbpo-pulse 1.4s ease-in-out infinite;
}

@keyframes bankersbpo-pulse {
	50% { opacity: 0.6; }
}

.tool__error {
	color: #b42318;
	font-weight: 600;
}

@media (max-width: 720px) {
	.tool {
		padding: 1.1rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tool button,
	.tool__progress > span {
		transition: none;
		animation: none !important;
	}
}

/* ---------- Bankers BPO engine (calculators, validators) ---------- */
.bbpo-tool {
	--t-brand: var(--brand, #0e3a5f);
	--t-brand-soft: var(--brand-soft, #e8eff6);
	--t-accent: var(--accent, #c08a2e);
	--t-surface: var(--surface, #ffffff);
	--t-sunken: var(--bg, #f5f7fa);
	--t-text: var(--text, #10223a);
	--t-muted: var(--muted, #5a6880);
	--t-border: var(--border, #dfe4ec);
	--t-on-brand: var(--on-brand, #fff);
	--t-track: color-mix(in srgb, var(--t-brand) 22%, var(--t-border));
	--t-good: #13795b;
	--t-bad: #b42318;
	--t-radius: var(--radius, 14px);
	--t-shadow: var(--shadow, 0 1px 2px rgba(16, 34, 58, .06), 0 8px 24px rgba(16, 34, 58, .06));
	color: var(--t-text);
	margin: 1.5rem 0 2rem;
	font-variant-numeric: tabular-nums;
}
.bbpo-tool *, .bbpo-tool *::before, .bbpo-tool *::after { box-sizing: border-box; }

.bbpo-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 760px) { .bbpo-grid { grid-template-columns: minmax(0, 1fr); } }

.bbpo-card { background: var(--t-surface); border: 1px solid var(--t-border); border-radius: var(--t-radius); box-shadow: var(--t-shadow); padding: 1.25rem; }
.bbpo-results { position: sticky; top: 1rem; }
@media (max-width: 760px) { .bbpo-results { position: static; } }

/* fields */
.bbpo-field { display: grid; gap: .45rem; padding: .85rem 0; border-bottom: 1px solid var(--t-border); }
.bbpo-field:first-child { padding-top: 0; }
.bbpo-field:last-of-type { border-bottom: 0; padding-bottom: 0; }
.bbpo-field-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.bbpo-field label, .bbpo-label { font-weight: 600; font-size: .925rem; color: var(--t-text); }
.bbpo-inputwrap { display: flex; align-items: center; background: var(--t-sunken); border: 1px solid var(--t-border); border-radius: 10px; overflow: hidden; min-width: 9.5rem; }
.bbpo-inputwrap:focus-within { border-color: var(--t-brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--t-brand) 20%, transparent); }
.bbpo-affix { padding: 0 .6rem; color: var(--t-muted); font-size: .9rem; }
.bbpo-num { width: 100%; border: 0; background: transparent; color: var(--t-text); font: inherit; font-weight: 600; padding: .5rem .6rem; text-align: right; outline: none; }
.bbpo-inputwrap .bbpo-affix + .bbpo-num { padding-left: 0; }
.bbpo-num-lg, .bbpo-select {
	text-align: left; font-size: 1.05rem; background: var(--t-sunken); border: 1px solid var(--t-border); border-radius: 10px; padding: .65rem .8rem; width: 100%; color: var(--t-text); font: inherit;
}
.bbpo-num-lg { font-size: 1.15rem; font-weight: 600; }
.bbpo-num-lg:focus, .bbpo-select:focus { outline: none; border-color: var(--t-brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--t-brand) 20%, transparent); }
.bbpo-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; }
.bbpo-hint { font-size: .8rem; color: var(--t-muted); min-height: 1em; }
.bbpo-hint:empty { display: none; }

.bbpo-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 99px; margin: .35rem 0; cursor: pointer;
	background: linear-gradient(to right, var(--t-brand) var(--fill, 0%), var(--t-track) var(--fill, 0%)); }
[dir="rtl"] .bbpo-slider { background: linear-gradient(to left, var(--t-brand) var(--fill, 0%), var(--t-track) var(--fill, 0%)); }
.bbpo-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--t-surface); border: 3px solid var(--t-brand); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.bbpo-slider::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--t-surface); border: 3px solid var(--t-brand); }

.bbpo-seg { display: flex; flex-wrap: wrap; background: var(--t-sunken); border: 1px solid var(--t-border); border-radius: 10px; padding: 3px; gap: 3px; }
.bbpo-seg input { position: absolute; opacity: 0; pointer-events: none; }
.bbpo-seg label { flex: 1 1 auto; text-align: center; padding: .45rem .7rem; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .875rem; color: var(--t-muted); }
.bbpo-seg input:checked + label { background: var(--t-surface); color: var(--t-brand); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.bbpo-seg input:focus-visible + label { outline: 2px solid var(--t-brand); outline-offset: 1px; }

.bbpo-inline { display: flex; gap: .5rem; }
.bbpo-inline .bbpo-num-lg { flex: 1; min-width: 0; }

.bbpo-btn { appearance: none; border: 1px solid var(--t-brand); background: var(--t-brand); color: var(--t-on-brand); font: inherit; font-weight: 600; font-size: .9rem; padding: .6rem 1rem; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.bbpo-btn:hover { filter: brightness(1.1); }
.bbpo-btn:disabled { opacity: .6; cursor: progress; }
.bbpo-btn-ghost { background: transparent; color: var(--t-brand); border-color: var(--t-border); padding: .45rem .8rem; font-size: .85rem; }
.bbpo-btn-ghost:hover { background: var(--t-brand-soft); filter: none; }
.bbpo-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }

/* results */
.bbpo-primary { display: grid; gap: .2rem; padding: 1rem 1.1rem; border-radius: 12px; background: var(--t-brand); color: var(--t-on-brand); }
.bbpo-primary.is-good { background: var(--t-good); color: #fff; }
.bbpo-primary.is-bad { background: var(--t-bad); color: #fff; }
.bbpo-primary-label { font-size: .85rem; opacity: .85; font-weight: 500; }
.bbpo-primary strong { font-size: clamp(1.6rem, 4vw, 2.1rem); line-height: 1.15; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.bbpo-sub { font-size: .85rem; opacity: .85; }
.bbpo-words { margin: .2rem 0 0; font-size: 1.1rem; line-height: 1.45; font-weight: 600; }

.bbpo-stats { margin: .9rem 0 0; display: grid; gap: 0; }
.bbpo-stats > div { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px dashed var(--t-border); }
.bbpo-stats > div:last-child { border-bottom: 0; }
.bbpo-stats dt { color: var(--t-muted); font-size: .9rem; }
.bbpo-stats dd { margin: 0; font-weight: 700; text-align: right; }
.bbpo-stats-wide dd { font-weight: 600; max-width: 65%; overflow-wrap: anywhere; }

.bbpo-split { margin-top: 1rem; }
.bbpo-split-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--t-border); gap: 2px; }
.bbpo-split-a { background: var(--t-brand); }
.bbpo-split-b { background: var(--t-accent); }
.bbpo-legend { list-style: none; margin: .7rem 0 0; padding: 0; display: grid; gap: .35rem; }
.bbpo-legend li { display: grid; grid-template-columns: auto 1fr auto 3rem; gap: .5rem; align-items: center; font-size: .9rem; }
.bbpo-legend i { width: 10px; height: 10px; border-radius: 3px; }
.bbpo-key-a { background: var(--t-brand); }
.bbpo-key-b { background: var(--t-accent); }
.bbpo-legend small { color: var(--t-muted); text-align: right; }

.bbpo-note, .bbpo-fineprint { font-size: .825rem; color: var(--t-muted); margin: .9rem 0 0; line-height: 1.5; }
.bbpo-error { margin: 0; padding: .85rem 1rem; border-radius: 10px; background: color-mix(in srgb, var(--t-bad) 10%, var(--t-surface)); color: var(--t-bad); font-weight: 600; }
.bbpo-empty { margin: 0; color: var(--t-muted); }

.bbpo-tags, .bbpo-checks { list-style: none; padding: 0; margin: .9rem 0 0; }
.bbpo-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.bbpo-tags li { padding: .25rem .6rem; border-radius: 99px; font-size: .8rem; font-weight: 700; }
.bbpo-checks { display: grid; gap: .4rem; }
.bbpo-checks li { font-size: .9rem; }
.is-yes { color: var(--t-good); }
.bbpo-tags .is-yes { background: color-mix(in srgb, var(--t-good) 12%, transparent); }
.is-no { color: var(--t-bad); }
.bbpo-tags .is-no { background: color-mix(in srgb, var(--t-bad) 10%, transparent); }

/* tables */
.bbpo-below:empty { display: none; }
.bbpo-tablecard { margin-top: 1rem; padding: 0; overflow: hidden; }
.bbpo-table-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--t-border); }
.bbpo-table-top h2, .bbpo-table-top h3 { margin: 0; font-size: 1rem; }
.bbpo-table-scroll { overflow: auto; max-height: 32rem; }
.bbpo-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.bbpo-table th, .bbpo-table td { padding: .6rem 1rem; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--t-border); }
.bbpo-table thead th { position: sticky; top: 0; background: var(--t-sunken); color: var(--t-muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.bbpo-table th:first-child { text-align: left; }
.bbpo-table tbody th { font-weight: 600; }
.bbpo-table tbody tr:hover { background: var(--t-sunken); }

/* tool grid shortcode */
.bbpo-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; list-style: none; padding: 0; margin: 1rem 0; }
.bbpo-cards a { display: grid; grid-template-columns: auto 1fr; gap: .25rem .9rem; height: 100%; padding: 1.1rem; background: var(--t-surface, #fff); border: 1px solid var(--t-border, #dfe4ec); border-radius: var(--t-radius, 14px); text-decoration: none; color: inherit; }
.bbpo-cards a:hover { border-color: var(--t-brand, #0e3a5f); }
.bbpo-cards .tool-badge { grid-row: span 2; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 10px; background: var(--t-brand-soft, #e8eff6); color: var(--t-brand, #0e3a5f); font-weight: 800; font-size: .75rem; letter-spacing: .02em; }
.bbpo-cards small { color: var(--t-muted, #5a6880); }

/* The engine renders its own cards, so the outer .tool wrapper is transparent. */
.tool.bbpo-tool { background: none; border: 0; box-shadow: none; padding: 0; }
.tool.bbpo-tool input, .tool.bbpo-tool select { width: auto; padding: 0; border: 0; background: none; }
.tool.bbpo-tool .bbpo-num-lg, .tool.bbpo-tool .bbpo-select { width: 100%; padding: .65rem .8rem; border: 1px solid var(--t-border); background: var(--t-sunken); }
.tool.bbpo-tool .bbpo-num { padding: .5rem .6rem; }
.tool.bbpo-tool .bbpo-slider { width: 100%; background: linear-gradient(to right, var(--t-brand) var(--fill, 0%), var(--t-track) var(--fill, 0%)); }
[dir="rtl"] .tool.bbpo-tool .bbpo-slider { background: linear-gradient(to left, var(--t-brand) var(--fill, 0%), var(--t-track) var(--fill, 0%)); }
.tool.bbpo-tool label { margin: 0; }

/* RTL: numbers and codes stay left-to-right; layout mirrors. */
[dir="rtl"] .bbpo-num, [dir="rtl"] .bbpo-mono, [dir="rtl"] .bbpo-table td, [dir="rtl"] .bbpo-stats dd, [dir="rtl"] .bbpo-legend b { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .bbpo-num { text-align: left; }
[dir="rtl"] .bbpo-stats dd, [dir="rtl"] .bbpo-table th, [dir="rtl"] .bbpo-table td { text-align: left; }
[dir="rtl"] .bbpo-table th:first-child { text-align: right; }
.tool.bbpo-tool .bbpo-slider { width: 100%; }
.tool.bbpo-tool .bbpo-seg input { position: absolute; }

/* Dark mode: the brand colour is light, so the empty slider track needs more of it to stay visible. */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .bbpo-tool { --t-track: color-mix(in srgb, var(--t-brand) 45%, var(--t-border)); }
}
:root[data-theme="dark"] .bbpo-tool { --t-track: color-mix(in srgb, var(--t-brand) 45%, var(--t-border)); }
