/* The public invoice page (studio-invoice.php) and its pay panel (invoice.js InvoicePublic / InvoicePayment), also used by the website Store's checkout (studio-cart.php). --inv-brand-top / --inv-brand-bot are the studio's colours */
.invoice-public {
	max-width: 600px;
	margin: 0 auto;
	padding: 20px;
}
.invoice-public-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	text-align: left;
	margin-bottom: 30px;
}
.invoice-public-header-right {
	text-align: right;
}
.invoice-public-studio-name {
	font-size: 16px;
	font-weight: 600;
	color: #333;
	margin-bottom: 4px;
}
.invoice-public-studio-addr {
	font-size: 13px;
	color: #666;
	line-height: 1.5;
}
.invoice-public-studio-contact {
	font-size: 13px;
	color: #666;
	line-height: 1.5;
}
.invoice-public-header-left .invoice-public-studio-contact:first-of-type {
	margin-top: 8px;
}
.invoice-public-logo {
	display: block;
	margin: 0 0 8px;
	max-height: 70px;
	max-width: 260px;
}
.invoice-public-studio {
	font-size: 24px;
	font-weight: bold;
	color: #333;
	margin-bottom: 5px;
}
.invoice-public-title {
	font-size: 20px;
	color: #666;
	text-transform: uppercase;
	letter-spacing: 1px;
	margin-bottom: 10px;
}
.invoice-public-box {
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 2px 10px rgba(0,0,0,0.1);
	padding: 25px;
	margin-bottom: 20px;
}
.invoice-public-info {
	display: flex;
	justify-content: space-between;
	margin-bottom: 20px;
	padding-bottom: 20px;
	border-bottom: 1px solid #eee;
}
.invoice-public-info-item {
	text-align: center;
}
.invoice-public-info-label {
	font-size: 11px;
	color: #999;
	text-transform: uppercase;
	margin-bottom: 5px;
}
.invoice-public-info-value {
	font-size: 14px;
	font-weight: 600;
	color: #333;
}
.invoice-public-status {
	display: inline-block;
	padding: 4px 12px;
	border-radius: 12px;
	font-size: 11px;
	font-weight: bold;
	text-transform: uppercase;
}
.invoice-status-unpaid {
	/* Orange, matching the staff screens; partial keeps the amber below */
	background: #ffe0b2;
	color: #8a4b08;
}
.invoice-status-paid {
	background: #d4edda;
	color: #155724;
}
.invoice-status-draft {
	background: #e2e3e5;
	color: #383d41;
}
.invoice-status-estimate {
	background: #cce5ff;
	color: #004085;
}
.invoice-status-canceled {
	background: #f8d7da;
	color: #721c24;
}
.invoice-public-billto {
	margin-bottom: 20px;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
}
.invoice-public-billto-info {
	min-width: 0;
}
.invoice-public-billto-pic {
	margin-top: 24px;
	max-width: 300px;
	max-height: 100px;
	object-fit: contain;
	flex-shrink: 0;
}
.invoice-public-billto-label {
	font-size: 11px;
	color: #999;
	text-transform: uppercase;
	margin-bottom: 5px;
}
.invoice-public-billto-name {
	font-size: 16px;
	font-weight: 600;
	color: #333;
}
.invoice-public-billto-addr {
	font-size: 14px;
	color: #555;
	line-height: 1.4;
	white-space: nowrap;
}
.invoice-public-terms {
	font-size: 13px;
	color: #666;
	line-height: 1.5;
	margin-top: 18px;
	padding-top: 14px;
	border-top: 1px solid #eee;
}
.invoice-public-items {
}
.invoice-public-items-header {
	display: flex;
	background: #f5f5f5;
	padding: 10px 15px;
	font-size: 11px;
	font-weight: bold;
	color: #666;
	text-transform: uppercase;
	border-radius: 4px 4px 0 0;
}
.invoice-public-item {
	display: flex;
	padding: 12px 15px;
	border-bottom: 1px solid #eee;
	font-size: 14px;
}
.invoice-public-item:last-child {
	border-bottom: none;
}
/* Descriptions have no length limit: long words and links wrap inside the column
   (min-width 0 lets the flex item shrink below its longest word) and typed line
   breaks are kept, while the amount columns hold their width */
.invoice-public-item-desc {
	flex: 1;
	min-width: 0;
	overflow-wrap: anywhere;
	word-break: break-word;
	white-space: pre-line;
	padding-right: 10px;
}
.invoice-public-item-qty {
	width: 60px;
	flex-shrink: 0;
	text-align: center;
}
.invoice-public-item-price {
	width: 80px;
	flex-shrink: 0;
	text-align: right;
}
.invoice-public-item-total {
	width: 90px;
	flex-shrink: 0;
	text-align: right;
	font-weight: 600;
}
.invoice-public-summary-lines {
	padding: 12px 15px 0;
	background: #f9f9f9;
}
.invoice-public-summary-row {
	display: flex;
	justify-content: flex-end;
	gap: 20px;
	font-size: 14px;
	color: #555;
	padding: 8px 0;
}
.invoice-public-summary-row span:last-child {
	min-width: 120px;
	text-align: right;
}
.invoice-public-total {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 20px;
	padding: 20px 15px;
	background: #f9f9f9;
	border-radius: 0 0 4px 4px;
}
.invoice-public-total-label {
	font-size: 14px;
	font-weight: bold;
	color: #333;
}
.invoice-public-total-amount {
	width: 120px;
	text-align: right;
	font-size: 24px;
	font-weight: bold;
	color: #333;
}
.invoice-public-pay {
	margin-top: 20px;
}
.invoice-public-paid-message {
	text-align: center;
	padding: 20px;
	background: #d4edda;
	color: #155724;
	border-radius: 8px;
	font-size: 16px;
}
/* A scheduled charge is neither owed now nor settled — its own colour rather than
   the green that means the money has arrived */
.invoice-public-pending-message {
	text-align: center;
	padding: 20px;
	background: #d6e4f7;
	color: #1c3f6e;
	border-radius: 8px;
	font-size: 16px;
	line-height: 1.5;
}
.invoice-public-canceled-message {
	text-align: center;
	padding: 20px;
	background: #f8d7da;
	color: #721c24;
	border-radius: 8px;
	font-size: 16px;
}
/* Sits above the payment box, so it is a notice rather than a replacement for it */
.invoice-public-failed-message {
	padding: 14px 18px;
	margin-bottom: 20px;
	background: #f8d7da;
	color: #721c24;
	border-radius: 8px;
	font-size: 14px;
	line-height: 1.5;
}
.invoice-public-error {
	text-align: center;
	padding: 40px;
	color: #666;
}
.invoice-public-error h2 {
	color: #333;
	margin-bottom: 10px;
}
#pay-invoice-form {
	margin-top: 20px;
}
#pay-invoice-form .stripe-element {
	padding: 12px;
	border: 1px solid #ddd;
	border-radius: 4px;
	background: #fff;
	margin-bottom: 15px;
}
#pay-invoice-form .btn-pay {
	width: 100%;
	padding: 15px;
	margin: 0px;
	font-size: 16px;
	font-weight: bold;
}
.payment-error {
	color: #dc3545;
	margin-bottom: 15px;
	padding: 10px;
	background: #f8d7da;
	border-radius: 4px;
}
.invoice-pay-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
	margin-bottom: 15px;
}
.invoice-pay-header h3 { margin: 0; }
.invoice-pay-tabs { display: flex; gap: 16px; }
.invoice-pay-tab {
	padding: 6px 12px;
	font-size: 13px;
	border: 1px solid #ddd;
	background: #f7f7f7;
	color: #555;
	cursor: pointer;
}
.invoice-pay-tab.active {
	background: var(--inv-brand-top, #4a9);
	border-color: var(--inv-brand-bot, #4a9);
	color: #fff;
	text-shadow: none;
}
.invoice-pay-save {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	font-size: 13px;
	color: #555;
	margin: 12px 0;
}
.invoice-pay-save input { width: auto; margin: 0; }
.invoice-status-partial {
	background: #fff3cd;
	color: #856404;
}
.invoice-public-subtotal-row {
	font-weight: 700;
}
.invoice-public-fee-total-row {
	font-weight: 700;
}
.invoice-public-payment-row span:nth-child(2) {
	width: 210px;
	text-align: right;
}
.invoice-public-balance-row {
	font-weight: bold;
	color: #333 !important;
}
.invoice-pay-amount-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}
.invoice-pay-amount-row label { font-size: 13px; color: #555; margin: 0; }
.invoice-pay-amount-wrap {
	display: flex;
	align-items: center;
	gap: 4px;
	font-size: 18px;
	font-weight: bold;
	color: #333;
}
.invoice-pay-amount-wrap input {
	width: 110px;
	text-align: right;
	font-size: 18px;
	font-weight: bold;
	padding: 6px 8px;
	border: 1px solid #ddd;
	border-radius: 4px;
	margin: 0;
}
.invoice-pay-partial-note {
	font-size: 12px;
	color: #0b5e52;
	background: #d1f0eb;
	border-radius: 4px;
	padding: 8px 10px;
	margin-bottom: 12px;
	text-align: center;
}
.invoice-payment-partial {
	font-size: 14px;
	color: #155724;
	background: #d4edda;
	border-radius: 4px;
	padding: 10px 12px;
	margin-bottom: 12px;
}
.invoice-public-tools {
	display: flex;
	gap: 12px;
	justify-content: center;
	margin: 32px 0px;
}
.invoice-public-tools .btn-gray { min-width: 150px; }

/* Narrow screens: give the item rows their width back (matches the 600px
   breakpoint the rest of the invoice screens use) */
@media (max-width: 600px) {
	.invoice-public-box {
		padding: 25px 15px;
	}
	/* The item and summary blocks reclaim the box padding so the amount columns
	   keep their width — a partly refunded payment prints a struck original and
	   what survives beside it on one row */
	.invoice-public-items {
		margin: 0px -10px;
	}
	/* A phone has no room for a description beside three amount columns: the
	   description takes its own line and the amounts sit under it on the right */
	.invoice-public-item {
		flex-wrap: wrap;
		row-gap: 6px;
	}
	.invoice-public-item .invoice-public-item-desc {
		flex-basis: 100%;
		padding-right: 0;
	}
	.invoice-public-item .invoice-public-item-qty {
		margin-left: auto;
	}
	.invoice-public-items-header .invoice-public-item-desc {
		white-space: nowrap;
	}
	.invoice-public-summary-lines {
		margin: 0px -10px;
	}
	.invoice-public-total {
		padding: 20px 5px;
	}
	/* A logo wide enough to crowd the address on a phone */
	.invoice-public-billto-pic {
		max-width: 165px;
	}
	/* Four info cells become two rows: number + status, then the two dates
	   (DOM order is number, date, due, status) */
	.invoice-public-info {
		flex-wrap: wrap;
		row-gap: 16px;
	}
	.invoice-public-info-item {
		flex: 0 0 50%;
	}
	.invoice-public-info-item:nth-child(1) { order: 1; }
	.invoice-public-info-item:nth-child(4) { order: 2; }
	.invoice-public-info-item:nth-child(2) { order: 3; }
	.invoice-public-info-item:nth-child(3) { order: 4; }
}

/* Print-to-PDF (?print=1): strip app chrome + the payment box, print only the
   invoice document (plus the powered-by branding at the bottom) */
@media print {
	body > *:not(.page) { display: none !important; }
	.page > *:not(#invoice-public-app):not(.ml-powered) { display: none !important; }
	.invoice-public-pay,
	.invoice-public-paid-message,
	.invoice-public-pending-message,
	/* An estimate's Approve / Decline box is for the screen; the printed estimate is the document itself */
	.invoice-approval,
	.invoice-sign-box,
	.document-public-signed,
	.document-preview-note,
	.invoice-public-tools { display: none !important; }
	.invoice-sig-section { break-inside: avoid; page-break-inside: avoid; }
	body, .page { background: #fff !important; margin: 0 !important; padding: 0 !important; }
	/* .page is an inline-block on screen; Chrome ignores break-inside: avoid under an inline-block ancestor, so print it as a block */
	.page { display: block !important; position: static !important; }
	.invoice-public { max-width: 100% !important; padding: 0 !important; }
	.invoice-public-box { box-shadow: none !important; border: 1px solid #eee; }
	/* A picture in the terms never splits across pages: it moves whole to the next one, capped so it always fits */
	.invoice-public-terms .markup-img, .invoice-public-terms img { display: block; break-inside: avoid; page-break-inside: avoid; }
	.invoice-public-terms img { max-height: 8in; width: auto; margin: 8px 0; }
}
