.spv-viewer,
.spv-viewer * { box-sizing: border-box; }

.spv-viewer {
	--spv-navy: #010c4e;
	--spv-blue: #16358c;
	--spv-paper: #edf0f5;
	--spv-border: #d6dae3;
	--spv-height: 760px;
	width: 100%;
	margin: 35px auto;
	color: #151a2d;
	background: #fff;
	border: 1px solid var(--spv-border);
	border-radius: 18px;
	box-shadow: 0 10px 30px rgba(1, 12, 78, .12);
	overflow: hidden;
	font-family: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.spv-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 18px;
	min-height: 70px;
	padding: 15px 20px;
	color: #fff;
	background: var(--spv-navy);
}

.spv-heading h2 { margin: 0; color: inherit; font-size: clamp(18px, 2.2vw, 25px); line-height: 1.25; }
.spv-open-file { flex: 0 0 auto; color: #fff !important; font-size: 14px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.spv-toolbar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px 14px;
	padding: 10px 12px;
	background: #f8f9fc;
	border-bottom: 1px solid var(--spv-border);
}

.spv-toolbar-group { display: flex; align-items: center; gap: 6px; }
.spv-pages-control { order: 1; }
.spv-zoom-control { order: 2; }
.spv-actions { order: 3; margin-left: auto; }
.spv-page-label { display: flex; align-items: center; gap: 5px; margin: 0; font-size: 13px; white-space: nowrap; }
.spv-page-input { width: 55px !important; height: 36px !important; min-height: 36px !important; margin: 0 !important; padding: 4px 5px !important; border: 1px solid #b9bfcb !important; border-radius: 7px !important; background: #fff !important; color: #111 !important; text-align: center; font: inherit !important; }

.spv-button,
.spv-viewer a.spv-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	min-height: 36px;
	margin: 0;
	padding: 7px 11px;
	color: var(--spv-navy) !important;
	background: #fff;
	border: 1px solid #b9bfcb;
	border-radius: 7px;
	box-shadow: none;
	cursor: pointer;
	font: 700 13px/1.2 "Nunito", system-ui, sans-serif;
	text-decoration: none !important;
	transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.spv-button:hover,
.spv-button:focus-visible,
.spv-viewer a.spv-button:hover,
.spv-viewer a.spv-button:focus-visible { color: #fff !important; background: var(--spv-blue); border-color: var(--spv-blue); outline: none; }
.spv-prev, .spv-next, .spv-zoom-in, .spv-zoom-out { padding: 3px; font-size: 24px; line-height: 1; }

.spv-document {
	position: relative;
	height: var(--spv-height);
	min-height: 480px;
	overflow: auto;
	overscroll-behavior: contain;
	background: var(--spv-paper);
	scroll-behavior: smooth;
	scrollbar-color: #8992a8 #e5e8ee;
}

.spv-pages {
	--spv-zoom: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 22px;
	width: max(100%, calc(100% * var(--spv-zoom)));
	min-height: 100%;
	padding: 24px;
}

.spv-page {
	position: relative;
	flex: 0 0 auto;
	width: min(calc((100% - 48px) * var(--spv-zoom)), 980px);
	aspect-ratio: var(--spv-page-ratio);
	background: #fff;
	box-shadow: 0 4px 16px rgba(18, 24, 45, .2);
}

.spv-page canvas { display: none; max-width: none; margin: 0 auto; background: #fff; }
.spv-page.is-rendered { width: max-content; max-width: none; aspect-ratio: auto; }
.spv-page.is-rendered canvas { display: block; }
.spv-page.is-rendered .spv-page-placeholder { display: none; }
.spv-page-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa0af; font-size: 18px; }
.spv-page-number { position: absolute; right: 8px; bottom: -19px; color: #697087; font-size: 11px; }

.spv-loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	color: var(--spv-navy);
	font-weight: 700;
}
.spv-loading[hidden] { display: none; }
.spv-spinner { width: 26px; height: 26px; border: 3px solid #cbd0dc; border-top-color: var(--spv-navy); border-radius: 50%; animation: spv-spin .8s linear infinite; }
@keyframes spv-spin { to { transform: rotate(360deg); } }

.spv-error { padding: 35px 20px; text-align: center; }
.spv-error[hidden] { display: none; }
.spv-error p { margin: 0 0 10px; }
.spv-fallback-link { display: inline-block; margin-top: 8px; padding: 10px 16px; color: #fff !important; background: var(--spv-navy); border-radius: 8px; font-weight: 700; text-decoration: none !important; }
.spv-notice { padding: 14px 16px; border-left: 4px solid #d63638; background: #fff1f1; }
.spv-print-frame { position: fixed; width: 1px; height: 1px; right: 0; bottom: 0; border: 0; opacity: 0; pointer-events: none; }

.spv-viewer:fullscreen,
.spv-viewer.is-fullscreen { width: 100vw; height: 100vh; margin: 0; border: 0; border-radius: 0; background: #fff; }
.spv-viewer:fullscreen .spv-document,
.spv-viewer.is-fullscreen .spv-document { height: calc(100vh - 130px); }

@media (max-width: 600px) {
	.spv-viewer { margin: 24px auto; border-radius: 14px; }
	.spv-heading { min-height: 62px; padding: 12px 14px; }
	.spv-heading h2 { font-size: 18px; }
	.spv-open-file { font-size: 12px; }
	.spv-toolbar { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 9px; }
	.spv-pages-control { grid-column: 1; justify-content: flex-start; }
	.spv-zoom-control { grid-column: 2; }
	.spv-actions { grid-column: 1 / -1; width: 100%; margin: 0; }
	.spv-actions .spv-button { flex: 1; }
	.spv-control-label { display: none; }
	.spv-page-label > span { display: none; }
	.spv-button, .spv-viewer a.spv-button { min-width: 40px; min-height: 40px; padding: 8px 10px; }
	.spv-page-input { width: 46px !important; height: 40px !important; min-height: 40px !important; }
	.spv-document { height: min(72vh, 760px); min-height: 520px; }
	.spv-pages { gap: 18px; width: 100%; padding: 14px 8px 28px; }
	.spv-page { width: calc(100% - 4px); }
	.spv-page.is-rendered { width: max-content; max-width: none; }
	.spv-page canvas { max-width: none; }
	.spv-fullscreen { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.spv-document { scroll-behavior: auto; }
	.spv-spinner { animation-duration: 1.5s; }
}
