:root {
	--bg: #f4f6fb;
	--panel: #ffffff;
	--border: #d6deeb;
	--text: #1f2a44;
	--muted: #5f6f8f;
	--accent: #2b6cf6;
	--accent-soft: #e8f0ff;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: "Segoe UI", Tahoma, sans-serif;
	background: var(--bg);
	color: var(--text);
	min-height: 100vh;
	overflow: hidden;
}

.top-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	padding: 12px 16px 0;
}

.beta-notice {
	margin: 10px 16px 0;
	padding: 10px 12px;
	border: 1px solid #f1c27a;
	border-radius: 10px;
	background: #fff4de;
	color: #7a4a00;
	font-size: 0.85rem;
	font-weight: 600;
	line-height: 1.4;
}

#orderPdfBtn {
	margin-left: 18px;
}

.total-toggle {
	margin-left: auto;
	font-weight: 700;
	background: #f9fbff;
	border: 1px solid black;
	border-radius: 8px;
	padding: 8px 12px;
	white-space: nowrap;
}

.top-totals-details {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	padding: 8px 16px 0;
}

.top-totals-details[hidden] {
	display: none;
}

.app {
	display: grid;
	grid-template-columns: 340px 1fr;
	gap: 16px;
	padding: 12px 16px 16px;
	height: calc(100vh - 114px);
	overflow: hidden;
}

.wait-dialog {
	position: fixed;
	inset: 0;
	background: rgba(31, 42, 68, 0.35);
	display: grid;
	place-items: center;
	z-index: 9999;
}

.wait-dialog.hidden {
	display: none;
}

.wait-dialog-card {
	background: #fff;
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 18px 20px;
	min-width: 300px;
	display: grid;
	grid-template-columns: 24px 1fr;
	gap: 12px;
	align-items: center;
	box-shadow: 0 12px 30px rgba(31, 42, 68, 0.18);
	font-size: 0.9rem;
	color: var(--text);
}

.wait-spinner {
	width: 20px;
	height: 20px;
	border: 3px solid #dce6fa;
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 1s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

.panel {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 12px;
	box-shadow: 0 2px 8px rgba(31, 42, 68, 0.08);
	padding: 14px;
	min-height: 0;
}

.panel h2 {
	margin: 0 0 12px;
	font-size: 1.05rem;
}

.left-panel {
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-width: 0;
	overflow: hidden;
}

.controls {
	display: grid;
	gap: 8px;
	flex-shrink: 0;
}

.grid-config {
	display: grid;
	grid-template-columns: 1fr 1fr auto;
	gap: 8px;
	align-items: end;
}

.grid-config label {
	display: grid;
	gap: 4px;
	font-size: 0.8rem;
	color: var(--muted);
}

.grid-config input {
	width: 100%;
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 6px 8px;
	font-size: 0.86rem;
	color: var(--text);
}

.controls label {
	font-size: 0.86rem;
	color: var(--muted);
}

.button-row {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

button,
.secondary-button {
	border: 1px solid black;
	background: #fff;
	color: var(--text);
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 0.86rem;
	cursor: pointer;
}

a.secondary-button {
	text-decoration: none;
	display: inline-flex;
	align-items: center;
}

button.primary {
	border-color: black;
	background: var(--accent);
	color: #fff;
}

.message {
	font-size: 0.82rem;
	min-height: 18px;
	color: var(--muted);
}

.led-total {
	font-size: 0.86rem;
	font-weight: 600;
	color: var(--text);
	padding: 6px 8px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: #f9fbff;
}

.taster-total {
	font-size: 0.86rem;
	font-weight: 600;
	color: var(--text);
	padding: 6px 8px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: #f9fbff;
}

.tree-root {
	list-style: none;
	margin: 0;
	padding: 4px 0 0;
	overflow: auto;
	flex: 1;
	min-height: 0;
}

.group > details > summary {
	cursor: pointer;
	list-style: none;
	font-weight: 600;
	color: var(--text);
	margin: 4px 0;
	padding: 6px 8px;
	border-radius: 6px;
	background: #f9fbff;
	border: 1px solid #edf2fa;
}

.group > details > summary::-webkit-details-marker {
	display: none;
}

.group-list {
	list-style: none;
	margin: 6px 0 8px 10px;
	padding: 0;
	border-left: 1px dashed var(--border);
}

.template-item {
	margin: 4px 0 4px 10px;
	padding: 7px 8px;
	border: 1px solid var(--border);
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	background: #fff;
	cursor: grab;
	user-select: none;
}

.template-item:active {
	cursor: grabbing;
}

.template-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 4px;
	overflow: hidden;
	flex: 1;
}

.template-name {
	font-size: 0.86rem;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.template-src {
	font-size: 0.74rem;
	color: var(--muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 190px;
}

.template-property {
	font-size: 0.76rem;
	font-weight: 600;
	color: #35508a;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.preview-icon {
	width: 36px;
	height: 36px;
	object-fit: contain;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: #fff;
	flex-shrink: 0;
}

.grid-wrap {
	display: block;
	min-height: 0;
	overflow: auto;
}

.grid {
	display: grid;
	grid-template-columns: repeat(var(--grid-cols, 4), 140px);
	grid-template-rows: repeat(var(--grid-rows, 4), 170px);
	gap: 10px;
	padding: 12px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: #fcfdff;
	width: max-content;
	margin: 0 auto;
}

.cell {
	border: 2px dashed #c5d2eb;
	border-radius: 10px;
	background: #fff;
	display: grid;
	place-items: center;
	position: relative;
	overflow: hidden;
}

.cell.drag-over {
	border-color: var(--accent);
	background: var(--accent-soft);
}

.cell.clipboard-ready {
	border-color: #2b6cf6;
	border-style: solid;
	background: #e8f0ff;
	cursor: pointer;
}

.cell img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	pointer-events: none;
}

.cell .placeholder {
	color: var(--muted);
	font-size: 0.82rem;
	text-align: center;
	padding: 8px;
}

.cell .slot-id {
	position: absolute;
	top: 6px;
	right: 8px;
	font-size: 0.72rem;
	color: #8a99b6;
	background: #fff;
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 1px 5px;
}

.cell .cell-texts {
	position: absolute;
	left: 6px;
	right: 6px;
	bottom: 6px;
	z-index: 2;
	display: grid;
	gap: 4px;
}

.cell .cell-text,
textarea.cell-text {
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 3px 6px;
	font-size: 0.75rem;
	background: rgba(255, 255, 255, 0.95);
	color: var(--text);
	font-family: inherit;
	resize: vertical;
	width: 100%;
	box-sizing: border-box;
	line-height: 1.4;
}

.layer-text-editor {
	margin: 16px 0 12px;
	padding: 12px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: #f9fbff;
	display: grid;
	gap: 8px;
}

.layer-text-editor-title {
	font-size: 0.72rem;
	font-weight: 700;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.layer-text-editor label {
	display: grid;
	gap: 4px;
	font-size: 0.8rem;
	color: var(--text);
}

@media (max-width: 1150px) {
	body {
		overflow: auto;
	}

	.top-actions {
		padding: 12px 12px 0;
	}

	#orderPdfBtn {
		margin-left: 0;
	}

	.total-toggle {
		margin-left: 0;
	}

	.top-totals-details {
		padding: 8px 12px 0;
	}

	.app {
		grid-template-columns: 1fr;
		overflow: auto;
		height: auto;
		padding: 12px;
		min-height: 100vh;
	}

	.grid-wrap {
		min-height: auto;
		overflow: visible;
	}

	.grid {
		grid-template-columns: repeat(var(--grid-cols, 4), minmax(90px, 1fr));
		grid-template-rows: repeat(var(--grid-rows, 4), minmax(110px, 1fr));
		width: 100%;
	}
}
.rotatable-img {
	transition: transform 0.3s;
}
.rotated-180 {
	transform: rotate(180deg);
}
.rotate-btn:focus {
	outline: 2px solid #2b6cf6;
}
/* LED-Verbindung */
.led-connect-panel {
	margin-top: 12px;
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 0;
}

.led-connect-panel summary {
	cursor: pointer;
	padding: 8px 12px;
	font-weight: 600;
	font-size: 0.95em;
	color: var(--muted);
	user-select: none;
}

.led-connect-controls {
	padding: 8px 12px 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.led-connect-controls label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 0.85em;
	color: var(--muted);
}

.led-connect-controls input[type="text"] {
	padding: 4px 8px;
	border: 1px solid var(--border);
	border-radius: 6px;
	font-size: 0.95em;
}

.led-connect-buttons {
	display: flex;
	gap: 6px;
	align-items: center;
}

.ws-status-indicator {
	display: inline-block;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	border: 1px solid #888;
	flex-shrink: 0;
}

.ws-disconnected {
	background: #bbb;
}

.ws-connected {
	background: #4caf50;
	border-color: #388e3c;
}

.ws-error {
	background: #f44336;
	border-color: #d32f2f;
}

#toggleLedNumbersBtn.active {
	background: var(--accent);
	color: #fff;
}