/* GLYDEV Invoices — "ledger paper" minimalism.
   Warm paper, ink type, one vermilion accent reserved for stamps & alerts. */

:root {
	--paper: #f5f2ea;
	--sheet: #fffdf8;
	--ink: #1b1a17;
	--ink-2: #4a4740;
	--ink-3: #8a857a;
	--rule: #e3ddd0;
	--rule-2: #d3ccbc;
	--accent: #c2410c;
	--accent-soft: #fbeee6;
	--ok: #2f6b3f;
	--ok-soft: #e8f0e6;
	--warn: #8a5a00;
	--warn-soft: #f8efd9;
	--radius: 10px;
	--display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
	--body: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;
	--mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
	--shadow: 0 1px 0 rgba(27, 26, 23, 0.04), 0 8px 24px -12px rgba(27, 26, 23, 0.12);
}

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

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font: 15px/1.55 var(--body);
	font-feature-settings: "ss01";
	-webkit-font-smoothing: antialiased;
	min-height: 100vh;
	/* faint ledger ruling */
	background-image: linear-gradient(to bottom, transparent 31px, rgba(27, 26, 23, 0.025) 32px);
	background-size: 100% 32px;
}

a {
	color: inherit;
	text-decoration-color: var(--rule-2);
	text-underline-offset: 3px;
}
a:hover {
	text-decoration-color: var(--ink);
}

:focus-visible {
	outline: 2px solid var(--ink);
	outline-offset: 2px;
	border-radius: 4px;
}

.num,
.mono {
	font-family: var(--mono);
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.01em;
}

/* ---------- shell ---------- */

.topbar {
	position: sticky;
	top: 0;
	z-index: 10;
	background: rgba(245, 242, 234, 0.88);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid var(--rule);
}
.topbar-inner {
	max-width: 1080px;
	margin: 0 auto;
	padding: 0 28px;
	height: 60px;
	display: flex;
	align-items: center;
	gap: 36px;
}
.wordmark {
	font-family: var(--display);
	font-size: 24px;
	letter-spacing: 0.01em;
	text-decoration: none;
	white-space: nowrap;
}
.wordmark span {
	color: var(--ink-3);
	font-style: italic;
}
.nav {
	display: flex;
	gap: 4px;
	flex: 1;
	overflow-x: auto;
}
.nav a {
	text-decoration: none;
	color: var(--ink-2);
	padding: 6px 12px;
	border-radius: 999px;
	font-size: 14px;
	white-space: nowrap;
}
.nav a:hover {
	background: rgba(27, 26, 23, 0.05);
	color: var(--ink);
}
.nav a[aria-current="page"] {
	color: var(--ink);
	background: var(--sheet);
	box-shadow: inset 0 0 0 1px var(--rule-2);
}
.logout {
	background: none;
	border: 0;
	color: var(--ink-3);
	font: inherit;
	font-size: 14px;
	cursor: pointer;
	padding: 6px 0;
}
.logout:hover {
	color: var(--ink);
}

main {
	max-width: 1080px;
	margin: 0 auto;
	padding: 40px 28px 96px;
	animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes rise {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
}

@media (prefers-reduced-motion: reduce) {
	main,
	.stagger > * {
		animation: none !important;
	}
}

.stagger > * {
	animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.stagger > *:nth-child(2) {
	animation-delay: 0.06s;
}
.stagger > *:nth-child(3) {
	animation-delay: 0.12s;
}
.stagger > *:nth-child(4) {
	animation-delay: 0.18s;
}

/* ---------- typography ---------- */

.eyebrow {
	font-size: 12px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--ink-3);
	margin: 0 0 8px;
}
h1 {
	font-family: var(--display);
	font-weight: 400;
	font-size: 44px;
	line-height: 1.05;
	letter-spacing: -0.01em;
	margin: 0;
}
h2 {
	font-family: var(--display);
	font-weight: 400;
	font-size: 26px;
	margin: 0 0 14px;
}
h3 {
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--ink-2);
	margin: 0 0 12px;
}
.muted {
	color: var(--ink-3);
}
.small {
	font-size: 13px;
}
.page-head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 24px;
	margin-bottom: 32px;
	flex-wrap: wrap;
}
.page-head p {
	margin: 8px 0 0;
	color: var(--ink-2);
}

/* ---------- surfaces ---------- */

.card {
	background: var(--sheet);
	border: 1px solid var(--rule);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 24px;
}
.card + .card {
	margin-top: 20px;
}
.grid {
	display: grid;
	grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
	gap: 20px;
	align-items: start;
}
.grid > * + .card,
.grid .card + .card {
	margin-top: 0;
}
.stack {
	display: grid;
	gap: 20px;
}
@media (max-width: 860px) {
	.grid {
		grid-template-columns: 1fr;
	}
	h1 {
		font-size: 36px;
	}
}

/* ---------- hero (latest invoice) ---------- */

.hero {
	position: relative;
	padding: 32px;
	overflow: hidden;
}
.hero-amount {
	font-family: var(--display);
	font-size: clamp(56px, 8vw, 84px);
	line-height: 0.95;
	letter-spacing: -0.02em;
	margin: 18px 0 10px;
	font-variant-numeric: lining-nums;
}
.hero-amount .cents {
	font-size: 0.45em;
	color: var(--ink-3);
	vertical-align: 0.62em;
	margin-left: 2px;
}
.hero-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 28px;
	color: var(--ink-2);
	font-size: 14px;
}
.hero-meta b {
	font-weight: 500;
	color: var(--ink);
}
.hero-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 28px;
	padding-top: 24px;
	border-top: 1px dashed var(--rule-2);
}
.hero .stamp {
	position: absolute;
	top: 28px;
	right: 28px;
}

/* ---------- stamps (status) ---------- */

.stamp {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-family: var(--mono);
	font-size: 11px;
	font-weight: 500;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	padding: 4px 10px;
	border: 1.5px solid currentColor;
	border-radius: 4px;
	transform: rotate(-2deg);
	white-space: nowrap;
}
.stamp-draft {
	color: var(--accent);
	background: var(--accent-soft);
}
.stamp-confirmed {
	color: var(--ink-2);
}
.stamp-sent,
.stamp-parsed {
	color: var(--ok);
	background: var(--ok-soft);
}
.stamp-failed {
	color: var(--accent);
}
.stamp-duplicate,
.stamp-processing {
	color: var(--ink-3);
}
td .stamp {
	transform: none;
	font-size: 10px;
	padding: 2px 7px;
}

/* ---------- buttons & forms ---------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 40px;
	padding: 0 18px;
	border-radius: 8px;
	border: 1px solid var(--rule-2);
	background: var(--sheet);
	color: var(--ink);
	font: 500 14px/1 var(--body);
	text-decoration: none;
	cursor: pointer;
	transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover {
	background: #fff;
	box-shadow: 0 2px 8px -4px rgba(27, 26, 23, 0.25);
}
.btn:active {
	transform: translateY(1px);
}
.btn-primary {
	background: var(--ink);
	border-color: var(--ink);
	color: var(--paper);
}
.btn-primary:hover {
	background: #000;
}
.btn-quiet {
	border-color: transparent;
	background: transparent;
	color: var(--ink-2);
}
.btn[disabled],
.btn[aria-disabled="true"] {
	opacity: 0.45;
	pointer-events: none;
}
.btn .arrow {
	transition: transform 0.15s ease;
}
.btn:hover .arrow {
	transform: translateX(2px);
}

label {
	display: block;
	font-size: 13px;
	font-weight: 500;
	color: var(--ink-2);
	margin-bottom: 6px;
}
.hint {
	display: block;
	font-size: 12.5px;
	color: var(--ink-3);
	margin-top: 6px;
	font-weight: 400;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
	width: 100%;
	font: 15px/1.4 var(--body);
	color: var(--ink);
	background: #fff;
	border: 1px solid var(--rule-2);
	border-radius: 8px;
	padding: 9px 12px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea {
	min-height: 84px;
	resize: vertical;
}
input:focus,
textarea:focus,
select:focus {
	outline: none;
	border-color: var(--ink);
	box-shadow: 0 0 0 3px rgba(27, 26, 23, 0.08);
}
.field {
	margin-bottom: 18px;
}
.fields-2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0 18px;
}
@media (max-width: 640px) {
	.fields-2 {
		grid-template-columns: 1fr;
	}
}
.input-prefix {
	position: relative;
}
.input-prefix span {
	position: absolute;
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--ink-3);
	font-family: var(--mono);
}
.input-prefix input {
	padding-left: 26px;
	font-family: var(--mono);
}

fieldset {
	border: 0;
	padding: 0;
	margin: 0;
}
.settings-section {
	display: grid;
	grid-template-columns: 240px minmax(0, 1fr);
	gap: 32px;
	padding: 32px 0;
	border-top: 1px solid var(--rule);
}
.settings-section:first-of-type {
	border-top: 0;
	padding-top: 0;
}
.settings-section > div:first-child p {
	color: var(--ink-3);
	font-size: 13.5px;
	margin: 0;
}
@media (max-width: 760px) {
	.settings-section {
		grid-template-columns: 1fr;
		gap: 16px;
	}
}
.sticky-save {
	position: sticky;
	bottom: 16px;
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	padding: 12px;
	margin-top: 12px;
	background: rgba(255, 253, 248, 0.92);
	backdrop-filter: blur(6px);
	border: 1px solid var(--rule);
	border-radius: 12px;
	box-shadow: var(--shadow);
}

/* template picker */
.templates {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 14px;
}
@media (max-width: 760px) {
	.templates {
		grid-template-columns: 1fr;
	}
}
.template-option {
	position: relative;
	display: block;
	margin: 0;
	cursor: pointer;
	border: 1px solid var(--rule-2);
	border-radius: 10px;
	background: #fff;
	overflow: hidden;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.template-option input {
	position: absolute;
	opacity: 0;
}
.template-option:has(input:checked) {
	border-color: var(--ink);
	box-shadow: 0 0 0 3px rgba(27, 26, 23, 0.1);
}
.template-option:has(input:focus-visible) {
	outline: 2px solid var(--ink);
	outline-offset: 2px;
}
.template-thumb {
	height: 210px;
	overflow: hidden;
	border-bottom: 1px solid var(--rule);
	background: #f0ede5;
	position: relative;
}
.template-thumb iframe {
	width: 816px;
	height: 1056px;
	border: 0;
	transform: scale(0.29);
	transform-origin: 0 0;
	pointer-events: none;
	background: #fff;
}
.template-label {
	padding: 12px 14px;
	color: var(--ink);
	font-size: 14px;
	font-weight: 600;
	margin: 0;
}
.template-label small {
	display: block;
	font-weight: 400;
	color: var(--ink-3);
	font-size: 12.5px;
	margin-top: 2px;
}
.template-label a {
	font-weight: 400;
	font-size: 12.5px;
	color: var(--ink-2);
}

/* ---------- tables ---------- */

.table-wrap {
	overflow-x: auto;
}
table.data {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}
table.data th {
	text-align: left;
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ink-3);
	padding: 0 12px 10px;
	border-bottom: 1px solid var(--rule-2);
	white-space: nowrap;
}
table.data td {
	padding: 12px;
	border-bottom: 1px solid var(--rule);
	vertical-align: middle;
}
table.data tr:last-child td {
	border-bottom: 0;
}
table.data .r {
	text-align: right;
}
table.data tbody tr {
	transition: background 0.12s ease;
}
table.data tbody tr.link:hover {
	background: #faf7ef;
	cursor: pointer;
}
table.data td:first-child,
table.data th:first-child {
	padding-left: 0;
}
table.data td:last-child,
table.data th:last-child {
	padding-right: 0;
}
table.data tfoot td {
	border-top: 1px solid var(--ink);
	border-bottom: 0;
	font-weight: 600;
}

/* ---------- weekly bars ---------- */

.weeks {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 10px;
}
.weeks li {
	display: grid;
	grid-template-columns: 92px minmax(0, 1fr) 64px;
	align-items: center;
	gap: 12px;
	font-size: 13.5px;
}
.weeks .bar {
	height: 10px;
	border-radius: 2px;
	background: repeating-linear-gradient(90deg, var(--rule) 0 2px, transparent 2px 6px);
	position: relative;
	overflow: hidden;
}
.weeks .bar i {
	position: absolute;
	inset: 0 auto 0 0;
	width: var(--w);
	background: var(--ink);
	border-radius: 2px;
	transform-origin: left;
	animation: grow 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.weeks li:nth-child(1) .bar i {
	background: var(--accent);
}
@keyframes grow {
	from {
		transform: scaleX(0);
	}
}
.weeks .h {
	text-align: right;
}

/* ---------- misc ---------- */

.kv {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 10px 20px;
	margin: 0;
	font-size: 14px;
}
.kv dt {
	color: var(--ink-3);
}
.kv dd {
	margin: 0;
	text-align: right;
}

.notice {
	border-radius: 8px;
	padding: 12px 14px;
	font-size: 14px;
	margin-bottom: 20px;
	border: 1px solid;
}
.notice ul {
	margin: 6px 0 0;
	padding-left: 18px;
}
.notice-ok {
	background: var(--ok-soft);
	border-color: #c8dcc8;
	color: #1f4a2b;
}
.notice-err {
	background: var(--accent-soft);
	border-color: #f1cdb9;
	color: #8a2d07;
}
.notice-warn {
	background: var(--warn-soft);
	border-color: #ecd9a8;
	color: #5c3d00;
}

.checklist {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 8px;
	font-size: 14px;
}
.checklist li {
	display: flex;
	gap: 10px;
	align-items: baseline;
}
.checklist li::before {
	content: "";
	flex: none;
	width: 12px;
	height: 12px;
	border: 1.5px solid var(--rule-2);
	border-radius: 3px;
	transform: translateY(1px);
}
.checklist li.done {
	color: var(--ink-3);
	text-decoration: line-through;
	text-decoration-color: var(--rule-2);
}
.checklist li.done::before {
	background: var(--ink);
	border-color: var(--ink);
}

.dropzone {
	display: flex;
	align-items: center;
	gap: 14px;
	border: 1.5px dashed var(--rule-2);
	border-radius: 10px;
	padding: 18px;
	background: rgba(255, 255, 255, 0.5);
	transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone.is-over {
	border-color: var(--ink);
	background: #fff;
}
.dropzone input[type="file"] {
	font: 13px var(--body);
	color: var(--ink-2);
	flex: 1;
	min-width: 0;
}
.dropzone input[type="file"]::file-selector-button {
	font: 500 13px var(--body);
	border: 1px solid var(--rule-2);
	background: #fff;
	border-radius: 6px;
	padding: 6px 12px;
	margin-right: 12px;
	cursor: pointer;
}

.address {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-family: var(--mono);
	font-size: 13.5px;
	background: #fff;
	border: 1px solid var(--rule-2);
	border-radius: 6px;
	padding: 4px 6px 4px 10px;
}
.copy {
	border: 0;
	background: var(--paper);
	border-radius: 4px;
	font: 500 11px var(--body);
	padding: 3px 8px;
	cursor: pointer;
	color: var(--ink-2);
}

.preview-frame {
	width: 100%;
	height: 1060px;
	border: 1px solid var(--rule);
	border-radius: var(--radius);
	background: #fff;
	box-shadow: var(--shadow);
	display: block;
}
@media (max-width: 860px) {
	.preview-frame {
		height: 760px;
	}
}

.empty {
	text-align: center;
	padding: 48px 24px;
}
.empty h2 {
	margin-bottom: 8px;
}
.empty p {
	color: var(--ink-2);
	max-width: 460px;
	margin: 0 auto 20px;
}

.row-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}
.divider {
	border: 0;
	border-top: 1px dashed var(--rule-2);
	margin: 20px 0;
}

/* ---------- login ---------- */

.login {
	min-height: 100vh;
	display: grid;
	place-items: center;
	padding: 24px;
}
.login-card {
	width: min(380px, 100%);
	text-align: center;
	animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.login-card .wordmark {
	display: inline-block;
	font-size: 34px;
	margin-bottom: 6px;
}
.login-card p {
	color: var(--ink-3);
	margin: 0 0 28px;
}
.pin {
	width: 100%;
	text-align: center;
	font: 500 28px/1 var(--mono) !important;
	letter-spacing: 0.5em;
	padding: 16px 12px 16px calc(12px + 0.5em) !important;
	border-radius: 12px !important;
}
.login-card .btn {
	width: 100%;
	height: 48px;
	margin-top: 14px;
	font-size: 15px;
}
.login-card .notice {
	text-align: left;
}

/* ---------- scaled Letter-size preview ---------- */
.preview-scale {
	position: relative;
	width: 100%;
	aspect-ratio: 816 / 1056;
	border: 1px solid var(--rule);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	overflow: hidden;
	background: #fff;
}
.preview-scale iframe {
	position: absolute;
	inset: 0 auto auto 0;
	width: 816px;
	height: 1056px;
	border: 0;
	transform: scale(var(--s, 1));
	transform-origin: 0 0;
}

/* ---------- small screens ---------- */
.nav {
	scrollbar-width: none;
}
.nav::-webkit-scrollbar {
	display: none;
}
@media (max-width: 640px) {
	.topbar-inner {
		padding: 0 16px;
		gap: 14px;
	}
	.wordmark {
		font-size: 20px;
	}
	.wordmark span {
		display: none;
	}
	.nav a {
		padding: 6px 9px;
	}
	main {
		padding: 28px 16px 72px;
	}
	.card,
	.hero {
		padding: 20px;
	}
	.address {
		max-width: 100%;
		overflow-wrap: anywhere;
	}
}
