:root {
	--bg: #0f1115;
	--card: #161a22;
	--text: #e6e6e6;
	--muted: #9aa0a6;
	--primary: #4ea1ff;
	--success: #2ecc71;
	--error: #ff5c5c;
	--border: #262b36;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }

.app-header {
	padding: 16px;
	position: sticky;
	top: 0;
	z-index: 10;
	background: rgba(10, 10, 10, 0.78);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.app-header h1 { margin: 0 0 8px 0; font-size: 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; filter: drop-shadow(0 2px 8px rgba(212,175,55,0.25)); }
.brand-titles h1 { margin: 0; font-size: 20px; letter-spacing: .3px; }
.brand-titles .tagline { display: block; font-size: 12px; color: #c9c9c9; opacity: .85; margin-top: 2px; }

.factory-select { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
input, select, button {
	padding: 10px 12px;
	border-radius: 10px;
	border: 1px solid rgba(255,255,255,0.14);
	background: rgba(28, 28, 32, 0.6);
	color: var(--text);
	backdrop-filter: blur(6px);
}
input:focus, select:focus, button:focus {
	outline: none;
	border-color: rgba(212,175,55,0.75);
	box-shadow: 0 0 0 3px rgba(212,175,55,0.18);
}
button { cursor: pointer; transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease, background-color .2s ease; }
button:hover { border-color: rgba(212,175,55,0.55); box-shadow: 0 10px 22px rgba(212,175,55,0.18); }
button:active { transform: translateY(0); }
button.secondary { background: rgba(255,255,255,0.02); color: var(--text); border-color: rgba(255,255,255,0.16); }
.btn-danger { background: rgba(255,92,92,0.1); border-color: rgba(255,92,92,0.5); color: #ff8a8a; }
.btn-danger:hover { background: rgba(255,92,92,0.18); border-color: rgba(255,92,92,0.75); }

.tabs { display: flex; gap: 8px; margin-top: 8px; }
.tab-btn { background: rgba(28,28,32,0.6); border: 1px solid rgba(255,255,255,0.14); }
.tab-btn.active { border-color: rgba(212,175,55,0.55); color: #ffd166; }

main { position: relative; z-index: 2; padding: 16px; display: grid; gap: 16px; }
.card {
	background: rgba(28, 28, 32, 0.6);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border: 1px solid rgba(255,255,255,0.14);
	border-radius: 14px;
	padding: 16px;
	box-shadow: 0 10px 28px rgba(0,0,0,0.45);
	position: relative;
}
.card::after {
	content: '';
	position: absolute;
	inset: 0;
	pointer-events: none;
	border-radius: inherit;
	box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 14px 40px rgba(0,0,0,0.35);
}
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid .full { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; margin-top: 10px; }

.table-container { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; }
thead th { position: sticky; top: 0; background: rgba(18,18,18,0.85); backdrop-filter: blur(6px); }
table tr:nth-child(even) { background: rgba(255,255,255,0.02); }
tbody tr:hover { background: rgba(255,255,255,0.05); transition: background .15s ease; }
table button { padding: 6px 10px; font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; }

.toast { position: fixed; bottom: 16px; right: 16px; background: rgba(18,18,18,0.9); border: 1px solid rgba(255,255,255,0.14); padding: 10px 14px; border-radius: 10px; z-index: 1001; backdrop-filter: blur(6px); }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }

.loader { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.35); backdrop-filter: blur(2px); font-weight: 600; font-size: 18px; letter-spacing: .3px; z-index: 1000; }
.loader[hidden] { display: none !important; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel { will-change: opacity, transform; }

.modal {
	position: fixed;
	inset: 0;
	display: grid;
	place-items: center;
	background: rgba(0,0,0,0.45);
	backdrop-filter: blur(2px);
	z-index: 1002;
}
.modal[hidden] { display: none !important; }
.modal-card {
	background: rgba(18, 18, 18, 0.85);
	backdrop-filter: blur(10px);
	border: 1px solid rgba(255,255,255,0.14);
	border-radius: 14px;
	padding: 16px;
	min-width: 320px;
	max-width: 560px;
	box-shadow: 0 12px 36px rgba(0,0,0,0.45);
}
.modal-card h3 { margin-top: 0; }
.modal-list { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-bottom: 12px; }
.modal-list table { width: 100%; border-collapse: collapse; }
.modal-list th, .modal-list td { padding: 6px; border-bottom: 1px solid var(--border); }
.gate-error { color: var(--error); font-size: 14px; font-weight: 600; }

button.btn-success { background: var(--success); border-color: var(--success); color: #0b1; font-weight: 600; }
button.btn-success:hover { filter: brightness(1.05); }

.chart-wrap { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: rgba(255,255,255,0.02); }
.legend .swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.badge { display: inline-block; padding: 2px 6px; font-size: 11px; border: 1px solid var(--border); border-radius: 6px; margin-right: 6px; }
.badge-paid { color: #8bc34a; border-color: #4a7a2e; background: rgba(139,195,74,0.1); }
tr.paid { opacity: 0.65; }

/* Item-Icon Row */
.item-cell { display: inline-flex; align-items: center; gap: 8px; }
.item-icon { width: 18px; height: 18px; object-fit: contain; border-radius: 3px; display: inline-block; }

@media (max-width: 900px) {
	.grid { grid-template-columns: 1fr; }
	.chart-wrap { grid-template-columns: 1fr; }
}

/* Toggle: Admin/Superadmin im Login-Modal */
.admin-toggle-wrap { user-select: none; }
.admin-toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.admin-toggle-track {
	position: relative;
	width: 52px; height: 28px;
	border-radius: 999px;
	background: rgba(255,255,255,0.12);
	border: 1px solid rgba(255,255,255,0.18);
	display: inline-block;
	transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.admin-toggle-thumb {
	position: absolute;
	left: 3px; top: 3px;
	width: 22px; height: 22px;
	border-radius: 50%;
	background: #e5e7eb;
	box-shadow: 0 2px 6px rgba(0,0,0,0.35);
	transition: transform .2s ease, background .2s ease;
}
.admin-toggle-input:focus-visible + .admin-toggle-track {
	box-shadow: 0 0 0 3px rgba(212,175,55,0.25);
}
.admin-toggle-input:checked + .admin-toggle-track {
	background: rgba(56, 142, 60, 0.22); /* soft green */
	border-color: rgba(76, 175, 80, 0.65);
}
.admin-toggle-input:checked + .admin-toggle-track .admin-toggle-thumb {
	transform: translateX(24px);
	background: #4caf50; /* green */
}
.admin-toggle-label { color: var(--muted); font-size: 13px; }

