/* NSerio brand tokens, as in the main Scripter app: Deep Purple (primary), Crimson (accent), Indigo (secondary). */
:root {
	--purple: #430362;
	--crimson: #c00306;
	--indigo: #2d2a6f;
	--gradient: linear-gradient(90deg, #430362, #c00306);
	--charcoal: #444444;
	--slate: #6b6b6b;
	--border: #dddddd;
	--panel: #f7f7f7;
	--card: #ffffff;
	--green: #2e7d32;
	--amber: #986801;
	--error-bg: #fbe3e3;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--panel);
	color: var(--charcoal);
	font: 16px/1.5 'Segoe UI', Arial, sans-serif;
}

.brand { background: var(--gradient); color: #fff; padding: 28px 0 30px; }
.brand-inner { max-width: 760px; margin: 0 auto; padding: 0 32px; }
.brand h1 { font-size: 1.7rem; font-weight: 600; margin: 0 0 6px; letter-spacing: 0.01em; }
.brand .lead { margin: 0; color: rgba(255, 255, 255, 0.88); }
.footer { max-width: 760px; margin: 0 auto; padding: 28px 32px 36px; display: flex; justify-content: center; align-items: center; border-top: 1px solid var(--border); }
.footer img { display: block; height: 36px; width: auto; opacity: 0.95; }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }
h2 { font-size: 1.25rem; font-weight: 600; color: var(--purple); margin: 0 0 12px; padding-left: 0.75rem; border-left: 4px solid var(--crimson); }
.hidden { display: none !important; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06); padding: 20px; margin-bottom: 16px; }
label { display: block; font-weight: 600; color: var(--indigo); margin: 14px 0 4px; }
.hint { font-weight: 400; color: var(--slate); font-size: 0.85rem; }
input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--charcoal); font: inherit; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
button { margin-top: 16px; padding: 10px 20px; border: 0; border-radius: 6px; background: var(--purple); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
button:hover:not(:disabled) { background: var(--indigo); }
button.secondary { background: transparent; color: var(--indigo); border: 1px solid var(--indigo); }
button.secondary:hover:not(:disabled) { background: var(--panel); }
button:disabled { opacity: 0.6; cursor: default; }
code { word-break: break-all; background: var(--panel); border: 1px solid var(--border); padding: 2px 6px; border-radius: 4px; color: var(--indigo); }
.help { color: var(--slate); font-size: 0.9rem; margin: 14px 0 0; }
.help.first { margin-top: 0; }
.promises { color: var(--slate); font-size: 0.9rem; padding-left: 20px; margin: 18px 0 0; }
.notice { background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--amber); border-radius: 4px; padding: 10px 14px; margin: 0 0 16px; }
.notice.error { color: var(--crimson); background: var(--error-bg); border-left-color: var(--crimson); border-color: var(--error-bg); }

.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 18px; counter-reset: step; }
.step { flex: 1; text-align: center; padding: 8px 4px; border-bottom: 3px solid var(--border); color: var(--slate); font-size: 0.9rem; counter-increment: step; }
.step::before { content: counter(step) ". "; }
.step.current { border-image: var(--gradient) 1; color: var(--purple); font-weight: 600; }
.step.done { border-bottom-color: var(--green); color: var(--green); }

.guide { padding-left: 22px; margin: 12px 0 18px; }
.guide li { margin-bottom: 10px; }
.copy-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.copy-row code { flex: 1; min-width: 200px; padding: 8px; }
button.small { margin-top: 0; padding: 6px 14px; }
#connect-form button + button { margin-left: 8px; }

/* Progress */
.run-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.run-head h2 { margin-bottom: 14px; }
.elapsed { font-variant-numeric: tabular-nums; color: var(--slate); font-size: 0.95rem; white-space: nowrap; }
.stages { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 16px; flex-wrap: wrap; }
.stage { flex: 1; min-width: 150px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); color: var(--slate); font-size: 0.9rem; }
.stage-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem; color: #fff; }
.stage.active { color: var(--purple); border-color: var(--purple); background: #fff; font-weight: 600; }
.stage.active .stage-dot { border-color: var(--crimson); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.stage.done { color: var(--green); border-color: var(--green); background: #fff; }
.stage.done .stage-dot { border-color: var(--green); background: var(--green); }
.stage.done .stage-dot::after { content: "\2713"; }
@keyframes spin { to { transform: rotate(360deg); } }

.meter { position: relative; height: 18px; background: var(--border); border-radius: 9px; overflow: hidden; }
.meter-fill { position: relative; height: 100%; width: 0; border-radius: 9px; background: var(--gradient); transition: width 0.8s ease; overflow: hidden; }
.meter-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%); background-size: 200% 100%; animation: sheen 1.6s linear infinite; }
.meter-fill.indeterminate { width: 35%; animation: slide 1.4s ease-in-out infinite; }
@keyframes sheen { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.meter-text { margin: 8px 0 18px; color: var(--indigo); font-weight: 600; font-variant-numeric: tabular-nums; }

.live { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.live-tile { border: 1px solid var(--border); border-top: 3px solid var(--crimson); border-radius: 6px; padding: 10px 12px; background: #fff; }
.live-number { margin: 0; font-size: 1.6rem; font-weight: 700; color: var(--purple); font-variant-numeric: tabular-nums; }
.live-label { margin: 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--slate); }
.tip { margin: 6px 0 0; padding-left: 0.75rem; border-left: 4px solid var(--indigo); color: var(--slate); font-size: 0.9rem; min-height: 1.4em; }

@media (prefers-reduced-motion: reduce) {
	.meter-fill::after, .stage.active .stage-dot, .meter-fill.indeterminate { animation: none; }
	.meter-fill { transition: none; }
}

/* Results */
.impact { border-radius: 8px; padding: 20px; margin-bottom: 16px; border: 2px solid var(--border); border-left-width: 8px; background: var(--card); }
.impact-headline { font-size: 1.5rem; font-weight: 700; margin: 0 0 6px; }
.impact.low { border-color: var(--green); }
.impact.low .impact-headline { color: var(--green); }
.impact.medium { border-color: var(--amber); }
.impact.medium .impact-headline { color: var(--amber); }
.impact.high { border-color: var(--crimson); }
.impact.high .impact-headline { color: var(--crimson); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.figure { background: var(--card); border: 1px solid var(--border); border-top: 3px solid var(--purple); border-radius: 6px; padding: 14px; }
.figure h3 { font-size: 0.85rem; font-weight: 600; color: var(--indigo); text-transform: uppercase; letter-spacing: 0.03em; margin: 0 0 8px; }
.figure .total { font-size: 1.7rem; font-weight: 700; color: var(--purple); margin: 0 0 6px; font-variant-numeric: tabular-nums; }
.figure dl { margin: 0; font-size: 0.9rem; color: var(--slate); }
.figure dl div { display: flex; justify-content: space-between; }
.figure dt, .figure dd { margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions button + button { margin-left: 0; }
