:root {
	color-scheme: light;
	--portal-fg: #1e1e1e;
	--portal-muted: #6b7280;
	--portal-bg: #f4f5f7;
	--portal-surface: #ffffff;
	--portal-border: #e2e4e9;
	--portal-primary: #be0f34;
	--portal-primary-hover: #9c0c2a;
	--portal-success: #15803d;
	--portal-danger: #b91c1c;
	--portal-alert-bg: #fef2f2;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
	font-size: 16px;
	line-height: 1.5;
	color: var(--portal-fg);
	background: var(--portal-bg);
	-webkit-text-size-adjust: 100%;
}

.portal {
	min-height: 100vh;
	padding: 16px;
	padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.portal-content {
	max-width: 720px;
	margin: 0 auto;
}

.portal-header {
	padding: 8px 4px 16px;
}

.portal-header h1 {
	font-size: 22px;
	margin: 0 0 4px;
}

.portal-subhead {
	margin: 0;
	color: var(--portal-muted);
	font-size: 14px;
}

.portal-card {
	background: var(--portal-surface);
	border: 1px solid var(--portal-border);
	border-radius: 10px;
	padding: 16px;
	margin-bottom: 12px;
}

.portal-card--alert { background: var(--portal-alert-bg); border-color: #fecaca; }
.portal-card--success { border-color: #86efac; }

.portal-card h1 { font-size: 20px; margin: 0 0 8px; }

.portal-section-title {
	font-size: 15px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--portal-muted);
	margin: 0 0 12px;
}

.portal-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
}

.portal-block { min-width: 0; }

.portal-label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--portal-muted);
	margin: 0 0 2px;
}

.portal-value {
	margin: 0;
	font-size: 16px;
	font-weight: 500;
	word-break: break-word;
}

.portal-lines {
	list-style: none;
	margin: 0;
	padding: 0;
}

.portal-line {
	padding: 12px 0;
	border-bottom: 1px solid var(--portal-border);
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.portal-line:last-child { border-bottom: 0; }

.portal-line__desc strong { font-weight: 600; }
.portal-line__sub {
	font-size: 13px;
	color: var(--portal-muted);
	margin-top: 2px;
}

.portal-line__meta {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	color: var(--portal-muted);
	font-size: 14px;
}

.portal-line__meta strong { color: var(--portal-fg); font-weight: 600; }
.portal-line--empty { color: var(--portal-muted); }

.portal-totals {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 6px 12px;
	margin: 0;
}

.portal-totals dt { color: var(--portal-muted); }
.portal-totals dd { margin: 0; font-weight: 500; }
.portal-totals__grand {
	font-size: 18px;
	font-weight: 700;
	padding-top: 8px;
	border-top: 1px solid var(--portal-border);
	margin-top: 4px;
	color: var(--portal-fg);
}

.portal-sign {
	position: relative;
}

.portal-canvas {
	display: block;
	width: 100%;
	height: 220px;
	background: #fafafa;
	border: 2px dashed #cbd0d9;
	border-radius: 8px;
	touch-action: none;
	margin-bottom: 8px;
}

.portal-field {
	margin-top: 12px;
}

.portal-field label {
	display: block;
	font-size: 13px;
	color: var(--portal-muted);
	margin-bottom: 4px;
}

.portal-field input {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--portal-border);
	border-radius: 8px;
	font-size: 16px;
	background: #fff;
	min-height: 44px;
}

.portal-field input:focus {
	outline: 2px solid var(--portal-primary);
	outline-offset: -1px;
	border-color: var(--portal-primary);
}

.portal-helper { font-size: 13px; color: var(--portal-muted); margin: 4px 0 8px; }

.portal-error {
	margin-top: 12px;
	padding: 10px 12px;
	background: var(--portal-alert-bg);
	border: 1px solid #fecaca;
	border-radius: 8px;
	color: var(--portal-danger);
	font-size: 14px;
}

.portal-btn {
	display: inline-block;
	padding: 12px 20px;
	border-radius: 8px;
	font-size: 15px;
	font-weight: 600;
	text-decoration: none;
	border: 1px solid transparent;
	cursor: pointer;
	min-height: 44px;
	background: #eef0f4;
	color: var(--portal-fg);
}

.portal-btn--ghost { background: transparent; border-color: var(--portal-border); }
.portal-btn--primary { background: var(--portal-primary); color: #fff; }
.portal-btn--primary:hover, .portal-btn--primary:active { background: var(--portal-primary-hover); }
.portal-btn--primary[disabled] { opacity: 0.6; cursor: not-allowed; }

.portal-btn--large {
	width: 100%;
	padding: 16px 20px;
	font-size: 16px;
	margin-top: 16px;
}

@media (min-width: 640px) {
	.portal { padding: 32px; }
	.portal-header h1 { font-size: 28px; }
	.portal-grid { grid-template-columns: 1fr 1fr; }
	.portal-line { flex-direction: row; align-items: center; justify-content: space-between; }
	.portal-line__desc { flex: 1; padding-right: 16px; }
}
