* { box-sizing: border-box; }

.rg-wrap {
	max-width: 800px;
	margin: 0 auto;
	font-family: inherit;
	padding: 0 12px;
}

/* Prevent iOS Safari from auto-zooming into inputs (anything under 16px triggers it). */
.rg-wrap input,
.rg-wrap textarea,
.rg-wrap select,
.rg-wrap button {
	font-size: 16px;
}

.rg-login-wrap {
	display: flex;
	justify-content: center;
	padding: 40px 0;
}

.rg-login-box {
	width: 100%;
	max-width: 380px;
	padding: 30px;
	border: 1px solid #ddd;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0,0,0,0.06);
	text-align: center;
}

.rg-login-box h2 {
	margin-top: 0;
	color: #1B2A5B;
}

.rg-login-box form {
	text-align: left;
}

.rg-login-box .rg-btn {
	display: block;
	width: auto;
	min-width: 140px;
	margin: 18px auto 0 auto;
}

.rg-login-box .rg-help-text {
	text-align: center;
}

.rg-login-box label,
.rg-wrap label {
	display: block;
	font-weight: 600;
	margin-bottom: 4px;
	margin-top: 12px;
}

.rg-login-box input[type="email"],
.rg-login-box input[type="password"],
.rg-field input,
.rg-field textarea {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #ccc;
	border-radius: 4px;
	box-sizing: border-box;
}

.rg-btn {
	display: inline-block;
	padding: 8px 16px;
	border-radius: 4px;
	border: none;
	cursor: pointer;
	text-decoration: none;
	font-size: 14px;
}

.rg-btn-primary {
	background: #1B2A5B;
	color: #fff;
}

.rg-btn-secondary {
	background: #eee;
	color: #222;
}

.rg-btn-small {
	padding: 4px 10px;
	font-size: 12px;
}

.rg-btn-danger {
	background: #b3261e;
	color: #fff;
}

.rg-btn-link {
	background: none;
	color: #1B2A5B;
	text-decoration: underline;
	padding: 0;
}

.rg-alert {
	padding: 10px 14px;
	border-radius: 4px;
	margin-bottom: 16px;
	transition: opacity 0.4s ease;
}

.rg-fade-out {
	opacity: 0;
}

.rg-alert-success {
	background: #e7f5e9;
	color: #2E7D32;
	border: 1px solid #2E7D32;
}

.rg-alert-actions {
	margin-top: 8px;
}

.rg-alert-actions .rg-btn {
	margin-right: 8px;
}

.rg-alert-error {
	background: #fdeceb;
	color: #b3261e;
	border: 1px solid #b3261e;
}

.rg-toolbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
	padding-bottom: 10px;
	border-bottom: 1px solid #eee;
}

.rg-inline-form {
	display: inline;
}

.rg-tabs {
	display: flex;
	gap: 4px;
	margin-bottom: 16px;
	border-bottom: 2px solid #eee;
}

.rg-tab-btn {
	padding: 10px 18px;
	background: none;
	border: none;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	color: #666;
	border-bottom: 3px solid transparent;
	margin-bottom: -2px;
}

.rg-tab-btn.active {
	color: #1B2A5B;
	border-bottom-color: #2E7D32;
}

.rg-tab-panel { display: none; }
.rg-tab-panel.active { display: block; }

.rg-field-row {
	display: flex;
	gap: 20px;
}

.rg-field { flex: 1; }

/* Line-item table: no fixed row height anywhere, textarea wraps and grows,
   so long descriptions are never cut off. */
.rg-items-input-table {
	width: 100%;
	border-collapse: collapse;
	margin-top: 8px;
}

.rg-items-input-table th,
.rg-items-input-table td {
	border: 1px solid #ddd;
	padding: 6px;
	vertical-align: top;
}

.rg-items-input-table textarea,
.rg-items-input-table input[type="number"] {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #ccc;
	border-radius: 4px;
	box-sizing: border-box;
	resize: vertical;
	min-height: 40px;
}

.rg-amount-input {
	display: flex;
	align-items: center;
	gap: 4px;
}

.rg-amount-input input[type="number"] {
	flex: 1;
	min-height: auto;
}

.rg-currency-prefix {
	display: inline-block;
	font-weight: 600;
	color: #555;
	margin-right: 4px;
}

.rg-receipts-table {
	width: 100%;
	border-collapse: collapse;
}

.rg-receipts-table th,
.rg-receipts-table td {
	border: 1px solid #eee;
	padding: 8px;
	text-align: left;
	font-size: 13px;
	vertical-align: middle;
}

.rg-row-actions {
	display: flex;
	align-items: center;
	gap: 6px;
}

.rg-radio {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-weight: normal;
	margin-right: 20px;
	cursor: pointer;
}

.rg-radio input[type="radio"] {
	margin: 0;
	width: 16px;
	height: 16px;
	flex-shrink: 0;
}

.rg-radio-group {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 6px;
}

/* ---------- Mobile optimization ---------- */

@media (max-width: 640px) {

	.rg-login-box {
		padding: 20px;
		box-shadow: none;
		border: none;
	}

	.rg-toolbar {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	.rg-field-row {
		flex-direction: column;
		gap: 0;
	}

	.rg-tabs {
		gap: 0;
	}

	.rg-tab-btn {
		flex: 1;
		padding: 10px 8px;
		font-size: 13px;
		text-align: center;
	}

	.rg-btn {
		width: 100%;
		text-align: center;
		padding: 12px 16px;
	}

	.rg-btn-small {
		width: auto;
		padding: 6px 12px;
	}

	/* Line-item input table: stack description above amount/remove instead
	   of squeezing 3 columns into a narrow screen. */
	.rg-items-input-table,
	.rg-items-input-table tbody,
	.rg-items-input-table tr,
	.rg-items-input-table td {
		display: block;
		width: 100%;
	}

	.rg-items-input-table thead { display: none; }

	.rg-item-row {
		border: 1px solid #ddd;
		border-radius: 6px;
		margin-bottom: 10px;
		padding: 8px;
	}

	.rg-items-input-table td {
		border: none;
		padding: 4px 0;
	}

	.rg-items-input-table td:before {
		content: attr(data-label);
		display: block;
		font-weight: 600;
		font-size: 12px;
		color: #666;
		margin-bottom: 2px;
	}

	#rg-add-row {
		width: 100%;
	}

	/* Past receipts: turn each row into a stacked card instead of a
	   horizontally-scrolling table. */
	.rg-receipts-table,
	.rg-receipts-table tbody,
	.rg-receipts-table tr,
	.rg-receipts-table td {
		display: block;
		width: 100%;
	}

	.rg-receipts-table thead { display: none; }

	.rg-receipts-table tr {
		border: 1px solid #eee;
		border-radius: 6px;
		margin-bottom: 12px;
		padding: 10px;
	}

	.rg-receipts-table td {
		border: none;
		padding: 4px 0;
		font-size: 14px;
	}

	.rg-receipts-table td:before {
		content: attr(data-label);
		display: inline-block;
		font-weight: 600;
		font-size: 11px;
		color: #666;
		text-transform: uppercase;
		margin-right: 6px;
	}

	.rg-row-actions {
		flex-direction: column;
		gap: 8px;
		margin-top: 8px;
	}

	.rg-row-actions .rg-btn {
		width: 100%;
	}

	/* Success banner: stack the message above its View/Download buttons,
	   and make those buttons easy to tap instead of sitting inline with text. */
	.rg-alert-success {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	.rg-alert-actions {
		display: flex;
		gap: 8px;
		width: 100%;
	}

	.rg-alert-actions .rg-btn {
		flex: 1;
		width: auto;
	}
}
