body {
	font-family: Arial, sans-serif;
	margin: 0 30px;
	color: #222;
	line-height: 1.4;
}
h2 {
	margin-bottom: 5px;
}

.container {
	max-width: 950px;
	margin: 0 auto;
	padding: 0 15px;
	box-sizing: border-box;
}
.payment-box {
	display: none;
}
#actions {
	padding: 30px 0 70px 0;
}
button {
	padding: 10px 15px;
	margin-right: 8px;
	cursor: pointer;
	font-size: 14px;
	border: none;
}
#invoice-date {
	border-bottom: 1px dotted #ccc;
	padding-bottom: 10px;
}
#archive-select,
#buyer-select {
	height: 36px;
	border-color: #cae2fc;
	margin-left: 5px;
}
#add-buyer-btn,
#actions > button:nth-child(1) {
	background: #2196f3;
	color: #fff;
	cursor: pointer;
	transition: background-color 0.2s, color 0.2s;
}
#add-buyer-btn:hover,
#actions > button:nth-child(1):hover {
	background: #1c7bc9;
	color: #fff;
}

#actions > button:nth-child(2) {
	background: #ff9b06;
	color: #fff;
	cursor: pointer;
	transition: background-color 0.2s, color 0.2s;
}
#actions > button:nth-child(2):hover {
	background: #ea8d03;
	color: #fff;
}
#actions > button:nth-child(3) {
	background: #8bc34a;
	color: #fff;
	cursor: pointer;
	transition: background-color 0.2s, color 0.2s;
}
#actions > button:nth-child(3):hover {
	background: #6e9b3b;
	color: #fff;
}

#delete-invoice-btn,
#delete-buyer-btn {
	color: #ff5722;
	padding: 3px 7px;
	border-radius: 50%;
	width: auto !important;
	transition: background-color 0.5s ease;
}
#delete-invoice-btn:hover,
#delete-buyer-btn:hover {
	color: #ffffff;
	padding: 3px 7px;
	border-radius: 50%;
	width: auto !important;
	background: #ff5722;
	transition: background-color 0.5s ease;
}
#delete-invoice-btn,
#delete-buyer-btn {
	position: relative;
}

#delete-invoice-btn .tooltip-text,
#delete-buyer-btn .tooltip-text {
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%);
	margin-bottom: 6px;

	background: #000;
	color: #fff;
	padding: 4px 8px;
	font-size: 12px;
	white-space: nowrap;

	opacity: 0;
	visibility: hidden;
	transition: opacity 0.8s ease;
}

#delete-invoice-btn:hover .tooltip-text,
#delete-buyer-btn:hover .tooltip-text {
	opacity: 1;
	visibility: visible;
}
.tooltip-btn {
	position: relative;
	background: #f0f7ff;
}

.tooltip-text {
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%);
	margin-bottom: 6px;

	background: #000;
	color: #fff;
	padding: 4px 8px;
	font-size: 12px;
	white-space: nowrap;

	opacity: 0;
	visibility: hidden;
	transition: opacity 0.8s ease;
}

.tooltip-btn:hover .tooltip-text {
	opacity: 1;
	visibility: visible;
}
.actions-number {
	width: 18px;
}
.actions-cell {
	width: 46px;
}
#invoice-table > tbody > tr > td.actions-cell > div > button:nth-child(1) {
	color: #8bc34a;
}
#invoice-table > tbody > tr > td.actions-cell > div > button:nth-child(2) {
	color: #f44336;
}
#invoice-table > tbody > tr > td.actions-cell > div > button {
	font-size: 20px;
	padding: 0;
	width: 20px;
	height: 20px;
	align-items: center;
	background: none;
	margin: 0;
	border-radius: 50%;
}

table {
	width: 100%;
	border-collapse: collapse;
	margin-top: 15px;
}
table th,
table td {
	border: 1px solid #cae2fc;
	padding: 8px;
	text-align: left;
}
table th {
	background: #f0f7ff;
}

input[type='text'],
input[type='number'] {
	width: 100%;
	border: none;
	outline: none;
	background: transparent;
	font-size: 14px;
}

.total-block {
	margin-top: 20px;
	text-align: right;
	font-size: 18px;
	font-weight: bold;
}
.signature {
	margin-top: 40px;
}

.payment-box {
	margin-top: 20px;
	border: 2px solid #000;
	padding: 20px;
}
.payment-title {
	text-align: center;
	font-weight: bold;
	font-size: 18px;
	margin-bottom: 25px;
}
.row {
	display: flex;
	align-items: center;
	margin-bottom: 10px;
}
.label {
	width: 160px;
	font-weight: normal;
}
.value {
	font-weight: bold;
}
.box {
	border: 2px solid #000;
	padding: 8px 15px;
	font-weight: bold;
	margin-left: 10px;
}
.iban-box {
	border: 2px solid #000;
	padding: 8px 15px;
	font-weight: bold;
	margin-left: 10px;
	flex-grow: 1;
	max-width: 300px;
}

#select {
	margin-top: 20px;
}
#buyer-block {
	margin-top: 20px;
}

.archive-block {
	margin: 0 0 20px 0;
	float: right;
}
#amount-text {
	display: inline-block;
}
#amount-text::first-letter {
	text-transform: uppercase;
}

.signature-block {
	margin-top: 40px;
	font-weight: bold;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.signature-images {
	position: relative;
	font-weight: bold;
	height: 50px;
	line-height: 60px;
}

.signature-img {
	height: 88px;
	position: absolute;
	left: 10%;
	bottom: 40%;
}

.seal-img {
	height: 140px;
	position: absolute;
	left: 19%;
	bottom: -70%;
	transform: rotate(354deg);
	transform-origin: center;
}

/* === Адаптация === */

/* Планшеты (768–1023px) */
@media (max-width: 1023px) {
	body {
		margin: 20px;
	}
	.container {
		padding: 0 15px;
	}
	.row {
		flex-wrap: wrap;
	}
	.iban-box {
		max-width: none;
		flex: 1;
	}
}

/* Мобильные (≤767px) */
@media (max-width: 767px) {
	body {
		/* margin: 15px; */
	}
	.container {
		padding: 0 10px;
	}

	h2 {
		font-size: 1.5em;
	}
	#actions button,
	#add-buyer-btn,
	#delete-buyer-btn {
		margin: 8px 0;
	}

	.row {
		flex-direction: column;
		align-items: flex-start;
	}
	.label {
		width: auto;
		margin-bottom: 5px;
	}
	.box,
	.iban-box {
		margin-left: 0;
		width: 100%;
		box-sizing: border-box;
	}
	.iban-box {
		margin-top: 5px;
		font-size: 14px;
	}

	/* Таблица с горизонтальной прокруткой */
	.table-wrapper {
		overflow-x: auto;
		margin-top: 20px;
	}

	table {
		min-width: 700px;
	}

	/* Подпись и печать — один под другим */
	.signature-images {
		left: 8%;
	}

	.signature-img,
	.seal-img {
		max-width: 220px;
	}

	.seal-img {
		transform: rotate(354deg) scale(0.9);
	}
}

@media (max-width: 480px) {
	.container {
		max-width: 480px;
		padding: 0;
		margin-bottom: 100px;
	}
	.signature-wrote {
		font-size: 14px;
	}
	.signature-images {
		left: 10%;
	}
	.signature-img {
		max-width: 180px;
		bottom: 40%;
		left: 10%;
	}
	.seal-img {
		max-width: 200px;
		transform: rotate(354deg) scale(0.8);
		bottom: -60%;
		left: 25%;
		height: 165px;
	}
	.actions-cell {
		width: 100%;
	}
	#actions button,
	#delete-buyer-btn {
		width: 100%;
		margin: 3px 0;
	}
	#add-buyer-btn {
		width: 90%;
		margin: 8px 0;
	}
	.archive-block {
		margin: 3px 0 20px 0;
	}
	#buyer-select {
		margin: 0px;
		width: 100%;
		padding-left: 5px;
	}
	table {
		min-width: 0;
	}
	.table-wrapper {
		overflow-x: visible;
	}

	#invoice-table thead {
		display: none;
	}

	#invoice-table,
	#invoice-table tbody {
		display: block;
		width: 100%;
	}

	/* === КАРТОЧКА === */
	#invoice-table tr {
		display: grid;
		grid-template-columns: auto 1fr;
		gap: 5px 12px;
		border: 1px solid #cae2fc;
		border-radius: 8px;
		margin-bottom: 14px;
		padding: 10px 20px 10px 10px;
		background: #fff;
	}

	/* === БАЗОВО ДЛЯ ЯЧЕЕК === */
	#invoice-table td {
		display: block;
		align-items: center;
		justify-content: space-between;
		border: none;
		padding: 5px;
	}

	/* === № СЛЕВА ВВЕРХУ === */
	#invoice-table td:first-child {
		grid-column: 1;
		grid-row: 1;
		font-weight: bold;
		font-size: 16px;
		color: #2196f3;
	}

	/* === ACTIONS СПРАВА ВВЕРХУ === */
	#invoice-table td.actions-cell {
		grid-column: 2;
		grid-row: 1;
		justify-content: flex-end;
		display: flex;
	}

	#invoice-table td.actions-cell > div {
		grid-column: 2;
		grid-row: 1;
		justify-content: flex-end;
		display: flex;
		gap: 5px;
	}

	/* === ОСТАЛЬНЫЕ СТРОКИ === */
	#invoice-table td:not(:first-child):not(.actions-cell) {
		grid-column: 1 / -1;
		color: #555;
	}

	/* === ПОДПИСИ === */
	#invoice-table td::before {
		content: '';
		font-size: 12px;
		color: #7a7a7a;
		flex: 0 0 25%;
		padding-left: 12px;
	}
	#invoice-table td:nth-child(1)::before {
		content: '№';
		color: #2196f3;
		padding: 0;
	}
	#invoice-table td:nth-child(2)::before {
		content: 'Найменування';
	}
	#invoice-table td:nth-child(3)::before {
		content: 'Кіл-сть';
	}
	#invoice-table td:nth-child(4)::before {
		content: 'Од.';
	}
	#invoice-table td:nth-child(4) {
		display: none;
	}
	#invoice-table td:nth-child(5)::before {
		content: 'Ціна';
	}

	#invoice-table td:nth-child(6)::before {
		content: 'Сума';
		font-size: 14px;
	}
	#invoice-table td:nth-child(6) {
		display: flex;
	}

	/* === СУММА === */
	#invoice-table td.sum {
		border-top: 2px solid #2196f3;
		padding-top: 12px;
		font-weight: 600;
		margin-top: 10px;
	}

	/* === INPUT === */
	#invoice-table input {
		width: 100%;
		border: 1px dotted #ededed;
		padding: 10px 0 10px 10px;
		margin-top: 5px;
	}
}
.container.hide-signature .signature-images {
	display: none !important;
}

@media print {
	#actions,
	#select,
	#toggle-signature,
	#buyer-select,
	.archive-block,
	.actions-cell {
		display: none;
	}
	button {
		display: none !important;
	}
	input {
		border: none !important;
	}
	input[type='text'],
	input[type='number'] {
		border: none;
		outline: none;
		background: transparent;
		font-size: 12px;
	}
	.container {
		max-width: none;
		padding: 0;
		font-size: 12px;
	}
	.payment-box {
		display: none;
	}
	#actions {
		margin-bottom: 20px;
	}
	.payment-title {
		font-size: 14px;
	}
	table th,
	table td {
		border: 1px solid #bbbbbb;
	}
	#invoice-table {
		width: 100%;
	}
	.table-wrapper {
		display: table;
	}
	.table {
		min-width: auto;
		width: 100%;
	}
	.actions-quantity {
		width: 60px;
	}
	#invoice-table > tbody > tr > td:nth-child(5) > input[type='number'] {
		width: 75px;
	}
	#invoice-table > tbody > tr > td:nth-child(5) {
	}
	.signature-wrote {
		font-size: 14px;
	}
	.signature-images {
		position: relative;
		font-weight: bold;
		height: 50px;
		line-height: 60px;
	}

	.signature-img {
		height: 80px;
		position: absolute;
		left: 3%;
		bottom: 44%;
	}

	.seal-img {
		height: 145px;
		position: absolute;
		left: 12%;
		bottom: -100%;
		transform: rotate(354deg);
		transform-origin: center;
	}
}
