:root {
	--ink: #f5f8f9;
	--ink-dim: rgba(245, 248, 249, .68);
	--line: rgba(245, 248, 249, .14);
	--teal: #1ba9b5;
	--teal-deep: #0b6770;
	--orange: #fe9305;
	--navy: #24213a;
	--font-ui: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
	/* One "paper millimetre": real mm in print, scaled down on screens narrower than A4. */
	--u: min(1mm, (100vw - 24px) / 210);
	color-scheme: dark;
}

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

body {
	margin: 0; min-height: 100vh;
	font-family: var(--font-ui); color: var(--ink);
	background:
		radial-gradient(1100px 700px at 108% -14%, rgba(27, 169, 181, .34), transparent 62%),
		radial-gradient(900px 620px at -6% 112%, rgba(254, 147, 5, .16), transparent 60%),
		linear-gradient(180deg, #2f2b47, #1b1929);
	background-attachment: fixed;
	-webkit-font-smoothing: antialiased;
}

h1, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }

/* ---------- Controls ---------- */

.bar {
	position: sticky; top: 0; z-index: 5;
	display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
	padding: 12px clamp(12px, 2vw, 28px);
	background: rgba(36, 33, 58, .88); backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--line);
}
.bar h1 { font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 26px; line-height: 1; margin-right: auto; }
.bar-logo { display: block; height: 44px; width: auto; }

.pill {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	height: 44px; padding: 0 1.1em; border-radius: 999px;
	border: 1px solid var(--line); background: rgba(255, 255, 255, .05);
	color: var(--ink); font-size: 15px; font-weight: 650; white-space: nowrap;
	text-decoration: none; cursor: pointer;
	transition: background .15s, transform .1s, filter .15s;
}
.pill:hover { background: rgba(255, 255, 255, .12); }
.pill:active { transform: scale(.97); }
.pill.primary {
	border: 0; color: #2c1800;
	background: linear-gradient(180deg, #ffbd5c 0%, #fe9305 52%, #e58100 100%);
	box-shadow: 0 6px 18px rgba(254, 147, 5, .3), 0 1px 0 rgba(255, 255, 255, .45) inset;
}
.pill.primary:hover { filter: brightness(1.06); }

.field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-dim); white-space: nowrap; }
.field input, .field select {
	height: 44px; padding: 0 12px; border-radius: 12px;
	border: 1px solid var(--line); background: rgba(0, 0, 0, .28);
	color: var(--ink); font-size: 16px; font-weight: 650; letter-spacing: 0; text-transform: none;
}
.field input[type="number"] { width: 5.2em; }
.field input[type="text"] { width: 6.4em; text-transform: uppercase; letter-spacing: .08em; }

.info { flex-basis: 100%; font-size: 14px; color: var(--ink-dim); }
.info b { color: var(--ink); font-weight: 650; }

/* ---------- Paper ---------- */

.sheets { display: grid; justify-content: center; gap: 22px; padding: 22px 12px 64px; }

.sheet {
	width: calc(var(--u) * 210); height: calc(var(--u) * 297);
	padding: calc(var(--u) * 10);
	display: flex; flex-direction: column; gap: calc(var(--u) * var(--gap));
	background: #fff; color: var(--navy);
	border-radius: 4px; box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
	overflow: hidden;
}

/* Plate heights and gaps add up to the 277 mm inside the page margins. */
body[data-per="3"] { --ph: 88; --gap: 6.5; --head: 11.5; --num: 12.5; }
body[data-per="4"] { --ph: 65.5; --gap: 5; --head: 9.5; --num: 10; }
body[data-per="6"] { --ph: 42.5; --gap: 4.4; --head: 7; --num: 7.2; }

.plate {
	flex: 0 1 calc(var(--u) * var(--ph)); min-height: 0;
	display: grid; grid-template-rows: calc(var(--u) * var(--head)) minmax(0, 1fr);
	border: calc(var(--u) * .6) solid var(--teal-deep);
	border-radius: calc(var(--u) * 2.6);
	overflow: hidden; break-inside: avoid;
}

.plate-head {
	display: flex; align-items: center; gap: calc(var(--u) * 3);
	padding: 0 calc(var(--u) * 3.5);
	border-bottom: calc(var(--u) * .6) solid var(--teal-deep);
	min-width: 0;
}
.plate-head img { display: block; height: 80%; width: auto; }
.plate-title { font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: calc(var(--u) * var(--head) * .5); line-height: 1; }
.plate-id { margin-left: auto; font-size: calc(var(--u) * var(--head) * .34); color: #5b5873; white-space: nowrap; font-variant-numeric: tabular-nums; }
.plate-id b { color: var(--navy); font-weight: 800; }

.plate-grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); min-height: 0; }

.pc {
	display: grid; place-items: center;
	border-right: calc(var(--u) * .35) solid var(--teal-deep);
	border-bottom: calc(var(--u) * .35) solid var(--teal-deep);
	font-size: calc(var(--u) * var(--num)); font-weight: 800; line-height: 1;
	font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.pc:nth-child(9n) { border-right: 0; }
.pc:nth-child(n+19) { border-bottom: 0; }
.pc.is-blank { background: #d3edf0; }

/* ---------- Print ---------- */

@page { size: A4 portrait; margin: 0; }

@media print {
	:root { --u: 1mm; color-scheme: light; }
	* { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
	body { background: #fff; min-height: 0; }
	.bar { display: none; }
	.sheets { display: block; padding: 0; }
	.sheet { height: 296mm; border-radius: 0; box-shadow: none; break-after: page; }
	.sheet:last-child { break-after: auto; }
}

@media (max-width: 560px) {
	.bar h1 { font-size: 22px; }
	.bar-logo { height: 38px; }
	.pill, .field input, .field select { height: 40px; }
}
