.kg-app {
	--kg-ink: #14213d;
	--kg-muted: #6b7280;
	--kg-line: #e5e7eb;
	--kg-bg: #f7f8fb;
	--kg-card: #ffffff;
	--kg-accent: #2563eb;
	--kg-in: #16a34a;
	--kg-out: #e11d48;
	max-width: 560px;
	margin: 0 auto;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--kg-ink);
	font-size: 16px;
	line-height: 1.45;
}
.kg-app *, .kg-app *::before, .kg-app *::after { box-sizing: border-box; }

/* Saldo */
.kg-hero {
	background: linear-gradient(140deg, #14213d 0%, #2563eb 100%);
	color: #fff;
	border-radius: 20px;
	padding: 22px 22px 18px;
	margin-bottom: 16px;
}
.kg-hello { margin: 0 0 10px; opacity: .85; font-weight: 600; }
.kg-label { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; opacity: .75; }
.kg-balance { margin: 2px 0 14px; font-size: 44px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.kg-balance.is-negative { color: #fecdd3; }
.kg-stats { display: flex; flex-wrap: wrap; gap: 8px; font-size: 14px; }
.kg-stats span { background: rgba(255,255,255,.14); border-radius: 999px; padding: 5px 12px; }

/* Cards & forms */
.kg-card {
	background: var(--kg-card);
	border: 1px solid var(--kg-line);
	border-radius: 16px;
	padding: 4px 16px;
	margin-bottom: 12px;
}
.kg-form summary {
	list-style: none;
	cursor: pointer;
	font-weight: 700;
	padding: 12px 0;
	display: flex;
	align-items: center;
	gap: 10px;
}
.kg-form summary::-webkit-details-marker { display: none; }
.kg-form[open] summary { border-bottom: 1px solid var(--kg-line); margin-bottom: 12px; }
.kg-ico {
	width: 28px; height: 28px; border-radius: 50%;
	display: inline-grid; place-items: center;
	color: #fff; font-weight: 800; font-size: 18px; line-height: 1;
}
.kg-ico-out { background: var(--kg-out); }
.kg-ico-in { background: var(--kg-in); }

.kg-form form { padding-bottom: 14px; }
.kg-form label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.kg-form label em { font-weight: 400; color: var(--kg-muted); font-style: normal; }
.kg-form input[type="text"],
.kg-form input[type="date"] {
	display: block; width: 100%; margin-top: 4px;
	font: inherit; font-size: 16px; color: var(--kg-ink);
	padding: 11px 12px; border: 1px solid var(--kg-line); border-radius: 10px; background: var(--kg-bg);
}
.kg-form input:focus { outline: 2px solid var(--kg-accent); outline-offset: 1px; background: #fff; }
.kg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kg-money { position: relative; display: block; }
.kg-money span { position: absolute; left: 12px; top: 50%; transform: translateY(-40%); color: var(--kg-muted); }
.kg-money input[type="text"] { padding-left: 28px; }

.kg-photo { cursor: pointer; }
.kg-photo input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.kg-photo-btn {
	display: flex; align-items: center; justify-content: center; gap: 8px;
	border: 2px dashed var(--kg-line); border-radius: 12px; padding: 14px;
	color: var(--kg-accent); font-weight: 700;
}
.kg-photo-btn::before { content: "📷"; }
.kg-photo input:focus + .kg-photo-btn { border-color: var(--kg-accent); }
.kg-photo img { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; margin-top: 8px; }
.kg-photo.has-photo .kg-photo-btn::after { content: " (wijzigen)"; font-weight: 400; }

.kg-btn {
	width: 100%; border: 0; border-radius: 12px; padding: 13px;
	font: inherit; font-weight: 700; color: #fff; background: var(--kg-out); cursor: pointer;
}
.kg-btn-in { background: var(--kg-in); }
.kg-btn:active { transform: translateY(1px); }

/* Notice */
.kg-notice { border-radius: 12px; padding: 11px 14px; margin-bottom: 12px; font-weight: 600; }
.kg-notice-ok { background: #dcfce7; color: #166534; }
.kg-notice-err { background: #ffe4e6; color: #9f1239; }

/* History */
.kg-h { font-size: 18px; margin: 20px 0 6px; }
.kg-month { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--kg-muted); margin: 16px 0 6px; }
.kg-empty { color: var(--kg-muted); }
.kg-list { list-style: none; margin: 0; padding: 0; background: var(--kg-card); border: 1px solid var(--kg-line); border-radius: 16px; overflow: hidden; }
.kg-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--kg-line); }
.kg-item:first-child { border-top: 0; }
.kg-thumb { flex: 0 0 48px; width: 48px; height: 48px; border-radius: 10px; overflow: hidden; }
.kg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kg-thumb-ph { display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #fff; background: var(--kg-out); }
.kg-kleedgeld .kg-thumb-ph, .kg-inkomst .kg-thumb-ph { background: var(--kg-in); }
.kg-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kg-desc { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kg-sub { font-size: 13px; color: var(--kg-muted); }
.kg-amount { font-weight: 700; white-space: nowrap; color: var(--kg-out); }
.kg-kleedgeld .kg-amount, .kg-inkomst .kg-amount { color: var(--kg-in); }
.kg-del { margin: 0; }
.kg-del button {
	border: 0; background: none; color: #9ca3af; font-size: 20px; line-height: 1;
	width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
}
.kg-del button:hover { background: #f3f4f6; color: var(--kg-out); }

/* Lightbox */
.kg-lightbox {
	position: fixed; inset: 0; z-index: 99999;
	background: rgba(0,0,0,.85); display: grid; place-items: center; padding: 20px;
}
.kg-lightbox[hidden] { display: none; }
.kg-lightbox img { max-width: 100%; max-height: 90vh; border-radius: 12px; }
.kg-lightbox button {
	position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%;
	border: 0; background: #fff; font-size: 22px; cursor: pointer;
}

/* Admin preview */
.kg-admin-preview { margin-top: 20px; }

/* Beginsaldo */
.kg-start .kg-thumb-ph { background: var(--kg-accent); }
.kg-start .kg-amount { color: var(--kg-accent); }

/* Standalone app page (no theme) */
body.kg-standalone {
	margin: 0;
	min-height: 100vh;
	background: #f7f8fb;
	padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
	-webkit-text-size-adjust: 100%;
}
.kg-foot { text-align: center; margin: 24px 0 8px; font-size: 14px; }
.kg-foot a { color: var(--kg-muted); }

/* Login */
.kg-login { padding: 20px; margin-top: 10vh; }
.kg-login h1 { margin-top: 0; }
.kg-login form p { margin: 0 0 12px; }
.kg-login label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.kg-login input[type="text"],
.kg-login input[type="password"] {
	display: block; width: 100%; font: inherit; font-size: 16px;
	padding: 11px 12px; border: 1px solid var(--kg-line); border-radius: 10px; background: var(--kg-bg);
}
.kg-login .login-remember label { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.kg-login input[type="submit"] {
	width: 100%; border: 0; border-radius: 12px; padding: 13px;
	font: inherit; font-weight: 700; color: #fff; background: var(--kg-accent); cursor: pointer;
}

/* Login slider */
.kg-slider { position: fixed; inset: 0; z-index: 0; background: #14213d; overflow: hidden; }
.kg-slide {
	position: absolute; inset: 0;
	background-size: cover; background-position: center;
	opacity: 0; transform: scale(1.06);
	transition: opacity 1.6s ease, transform 7s ease-out;
}
.kg-slide.is-active { opacity: 1; transform: scale(1); }
.kg-slider::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,33,61,.15), rgba(20,33,61,.55)); }
.kg-is-login .kg-app { position: relative; z-index: 1; }
.kg-is-login .kg-login {
	background: rgba(255,255,255,.88);
	-webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
	border-color: rgba(255,255,255,.6);
	box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
@media (prefers-reduced-motion: reduce) { .kg-slide { transition: opacity .3s; transform: none; } }

/* Admin preview of slides */
.kg-slides-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.kg-slides-preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; }

/* 1.3.0: profielfoto naast het saldo */
.kg-hero-top { display: flex; align-items: center; gap: 16px; }
.kg-hero-text { min-width: 0; }
.kg-avatar-form { margin: 0; flex: 0 0 auto; }
.kg-avatar {
	position: relative; display: block; width: 76px; height: 76px; border-radius: 50%;
	cursor: pointer; background: rgba(255,255,255,.18);
	box-shadow: 0 0 0 3px rgba(255,255,255,.55);
}
.kg-avatar input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.kg-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.kg-avatar-initial { display: grid; place-items: center; width: 100%; height: 100%; font-size: 32px; font-weight: 800; }
.kg-avatar-edit {
	position: absolute; right: -2px; bottom: -2px; width: 28px; height: 28px; border-radius: 50%;
	display: grid; place-items: center; font-size: 14px; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.kg-avatar input:focus-visible ~ .kg-avatar-edit { outline: 2px solid #fff; outline-offset: 2px; }
.kg-avatar.is-busy img { opacity: .5; }
@media (max-width: 380px) {
	.kg-avatar { width: 62px; height: 62px; }
	.kg-balance { font-size: 38px; }
}

/* 1.3.0: melding onder saldo */
.kg-tip {
	display: flex; gap: 10px; align-items: flex-start;
	margin: -4px 0 16px; padding: 11px 14px; border-radius: 12px;
	background: #fef3c7; color: #78350f; font-size: 14px; line-height: 1.4;
}

/* 1.3.0: compacter inlogscherm, foto beter zichtbaar */
.kg-is-login .kg-app { max-width: 380px; }
.kg-is-login .kg-login {
	padding: 16px 18px 6px;
	background: rgba(255,255,255,.78);
}
.kg-login .kg-h { font-size: 20px; margin: 0 0 2px; }
.kg-login-sub { margin: 0 0 12px; font-size: 14px; color: var(--kg-muted); }
.kg-login form p { margin: 0 0 10px; }
.kg-login label { font-size: 13px; margin-bottom: 3px; }
.kg-login input[type="text"],
.kg-login input[type="password"] { padding: 9px 11px; background: rgba(255,255,255,.9); }
.kg-login input[type="submit"] { padding: 11px; }
.kg-slider::after { background: linear-gradient(180deg, rgba(20,33,61,0) 0%, rgba(20,33,61,0) 45%, rgba(20,33,61,.5) 100%); }

@media (max-width: 640px) {
	/* Kaart onderin, zodat de foto erboven vrij in beeld is */
	body.kg-standalone.kg-is-login {
		min-height: 100vh; min-height: 100dvh;
		display: flex; flex-direction: column; justify-content: flex-end;
		box-sizing: border-box;
		padding-bottom: max(14px, env(safe-area-inset-bottom));
	}
	.kg-is-login .kg-app { width: 100%; }
	.kg-is-login .kg-login { margin-top: 0; margin-bottom: 0; border-radius: 18px; }
	.kg-login .login-remember { font-size: 13px; }
}
