/* =========================================================
   Krafthand Angebote – Frontend-Oberfläche
   ========================================================= */
.kha-fe {
	--kha-blue: #0069b4;
	--kha-blue-dark: #00568f;
	--kha-ink: #1a2332;
	--kha-muted: #6c7789;
	--kha-line: #e7ecf3;
	--kha-bg: #f5f7fa;
	--kha-orange: #ff6a00;
	--kha-radius: 12px;
	--kha-shadow: 0 1px 2px rgba(26,35,50,.04), 0 6px 20px rgba(26,35,50,.06);

	width: 100%;
	max-width: 1240px;
	margin: 0 auto;
	color: var(--kha-ink);
	font-size: 15px;
	line-height: 1.55;
	box-sizing: border-box;
}
.kha-fe *, .kha-fe *::before, .kha-fe *::after { box-sizing: border-box; }
.kha-fe a:not(.kha-fe-btn):not(.button) { color: var(--kha-blue); }

/* ---------- Karten ---------- */
.kha-card {
	background: #fff;
	border: 1px solid var(--kha-line);
	border-radius: var(--kha-radius);
	box-shadow: var(--kha-shadow);
	padding: 26px 28px;
	margin: 0 0 22px;
}
.kha-card-flush { padding: 0; overflow: hidden; }
.kha-card-title {
	margin: 0 0 20px;
	padding-bottom: 14px;
	border-bottom: 2px solid var(--kha-bg);
	font-size: 1.15em;
	font-weight: 700;
	color: var(--kha-ink);
	letter-spacing: .01em;
}

/* ---------- Hinweise ---------- */
.kha-fe-notice {
	padding: 12px 16px;
	border-radius: 10px;
	margin: 0 0 20px;
	background: var(--kha-bg);
	border: 1px solid var(--kha-line);
}
.kha-fe-ok  { background: #e8f6ee; border-color: #bfe6cd; color: #1c7a3d; }
.kha-fe-err { background: #fdecec; border-color: #f6c9c6; color: #b3261e; }

/* ---------- Hinweiskarte (Login / kein Zugriff) ---------- */
.kha-fe-gate {
	max-width: 520px; margin: 40px auto; text-align: center;
	background: #fff; border: 1px solid var(--kha-line); border-radius: 16px;
	box-shadow: var(--kha-shadow); padding: 44px 40px;
}
.kha-fe-gate-icon {
	width: 64px; height: 64px; margin: 0 auto 22px;
	display: flex; align-items: center; justify-content: center;
	border-radius: 50%; background: #eaf3fb; color: var(--kha-blue);
}
.kha-fe-gate-title { margin: 0 0 10px; font-size: 1.4em; font-weight: 800; color: var(--kha-ink); }
.kha-fe-gate-text { margin: 0 auto 26px; max-width: 380px; color: var(--kha-muted); font-size: 1.02em; }
.kha-fe-gate-action { margin-top: 4px; }
.kha-fe-gate-action .kha-fe-btn { padding: 12px 28px; font-size: 16px; }

/* ---------- Kopfzeile der Liste ---------- */
.kha-fe-head {
	display: flex; align-items: center; justify-content: space-between;
	gap: 18px; margin: 0 0 20px;
}
.kha-fe-head h2 { margin: 0; font-size: 1.6em; font-weight: 800; letter-spacing: -.01em; }
.kha-fe-newform { margin: 0; }
.kha-fe-head-actions { display: flex; align-items: center; gap: 16px; }
.kha-fe-logout { color: var(--kha-muted); text-decoration: none; font-size: .92em; font-weight: 600; white-space: nowrap; }
.kha-fe-logout:hover { color: var(--kha-blue); text-decoration: underline; }
.kha-fe-topbar { margin: 0 0 18px; }
.kha-fe-back { text-decoration: none; font-weight: 600; }
.kha-fe-back:hover { text-decoration: underline; }

/* ---------- Buttons ---------- */
.kha-fe-btn {
	display: inline-flex; align-items: center; justify-content: center;
	padding: 11px 22px; border: 0; border-radius: 9px;
	background: var(--kha-blue); color: #fff;
	font-size: 15px; font-weight: 600; line-height: 1; cursor: pointer;
	text-decoration: none; transition: background .15s ease, transform .05s ease, box-shadow .15s ease;
	box-shadow: 0 2px 8px rgba(0,105,180,.25);
}
.kha-fe-btn:hover { background: var(--kha-blue-dark); color: #fff; box-shadow: 0 4px 14px rgba(0,105,180,.32); }
.kha-fe-btn:active { transform: translateY(1px); }
.kha-fe-save { margin: 22px 0; text-align: right; }
.kha-fe-save .kha-fe-btn { padding: 13px 30px; font-size: 16px; }

/* ---------- Listentabelle ---------- */
.kha-fe-table { width: 100%; border-collapse: collapse; }
.kha-fe-table th, .kha-fe-table td { text-align: left; padding: 14px 18px; vertical-align: middle; }
.kha-fe-table thead th {
	background: var(--kha-bg); color: var(--kha-muted);
	font-size: .8em; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
	border-bottom: 1px solid var(--kha-line);
}
.kha-fe-table tbody tr { border-bottom: 1px solid var(--kha-line); transition: background .12s ease; }
.kha-fe-table tbody tr:last-child { border-bottom: 0; }
.kha-fe-table tbody tr:hover { background: #fafbfd; }
.kha-fe .kha-right { text-align: right; }
.kha-fe-nr { color: var(--kha-muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.kha-fe-objekt { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; }
.kha-fe-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 2px rgba(0,0,0,.05) inset; }
.kha-fe-sum { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.kha-fe-actions { white-space: nowrap; text-align: right; }
.kha-fe-link {
	color: var(--kha-blue); text-decoration: none; margin-left: 14px;
	background: none; border: 0; padding: 0; font-size: .95em; font-weight: 600; cursor: pointer;
}
.kha-fe-actions .kha-fe-link:first-child { margin-left: 0; }
.kha-fe-link:hover { text-decoration: underline; }
.kha-fe-link-danger { color: #c0392b; }
.kha-fe-inline { display: inline; margin: 0; }
.kha-fe-empty { text-align: center; color: var(--kha-muted); }

/* ---------- Formular (form-table aus dem Backend) ---------- */
.kha-fe .form-table { width: 100%; border-collapse: collapse; margin: 0; }
.kha-fe .form-table th {
	width: 230px; text-align: left; vertical-align: top;
	padding: 12px 18px 12px 0; font-weight: 600; color: var(--kha-ink);
}
.kha-fe .form-table td { padding: 9px 0; vertical-align: top; }
.kha-fe .form-table tr + tr th, .kha-fe .form-table tr + tr td { border-top: 1px solid var(--kha-bg); }

.kha-fe input[type="text"],
.kha-fe input[type="number"],
.kha-fe select,
.kha-fe textarea {
	padding: 10px 12px; border: 1px solid #cdd4de; border-radius: 8px;
	font-size: 15px; background: #fff; color: var(--kha-ink); width: 100%; max-width: 480px;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.kha-fe textarea { max-width: 100%; }
.kha-fe input:focus, .kha-fe select:focus, .kha-fe textarea:focus {
	outline: 0; border-color: var(--kha-blue); box-shadow: 0 0 0 3px rgba(0,105,180,.15);
}
.kha-fe .description { color: var(--kha-muted); font-size: .85em; margin: 5px 0 0; }
.kha-fe select[required] + .description { margin-top: 5px; }

/* ---------- Positionen-Builder ---------- */
.kha-fe .kha-builder { margin: 4px 0 0; }
.kha-fe .kha-add-row { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.kha-fe .kha-add-row select { min-width: 340px; max-width: 100%; margin: 0; }
.kha-fe #kha_add_produkt {
	display: inline-flex; align-items: center; padding: 10px 18px;
	border: 1px solid var(--kha-blue); border-radius: 8px;
	background: #fff; color: var(--kha-blue); cursor: pointer; font-size: 14px; font-weight: 600;
	transition: background .15s ease, color .15s ease;
}
.kha-fe #kha_add_produkt:hover { background: var(--kha-blue); color: #fff; }

/* Abgerundeter, scrollbarer Rahmen um die Positionen-Tabelle */
.kha-fe .kha-pos-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--kha-line);
	border-radius: 12px;
	background: #fff;
	margin: 0 0 4px;
}
.kha-fe .kha-positionen { width: 100%; min-width: 760px; border-collapse: collapse; margin: 0; background: transparent; }
.kha-fe .kha-positionen thead th {
	background: var(--kha-bg); color: var(--kha-muted);
	font-size: .74em; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
	text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--kha-line); white-space: nowrap;
}
.kha-fe .kha-positionen thead th:first-child { border-top-left-radius: 12px; padding-left: 16px; }
.kha-fe .kha-positionen thead th:last-child { border-top-right-radius: 12px; }
.kha-fe .kha-positionen tbody td { padding: 12px; border-top: 1px solid var(--kha-line); vertical-align: middle; }
.kha-fe .kha-positionen tbody td:first-child { padding-left: 16px; font-weight: 600; }
.kha-fe .kha-positionen tbody tr:first-child td { border-top: 0; }
.kha-fe .kha-positionen tbody tr:hover { background: #f8fafc; }
.kha-fe .kha-positionen img { border-radius: 7px; vertical-align: middle; box-shadow: 0 0 0 1px rgba(0,0,0,.05); }
.kha-fe .kha-positionen input[type="text"],
.kha-fe .kha-positionen input[type="number"] { max-width: 100%; padding: 9px 11px; border-radius: 8px; }
.kha-fe .kha-positionen textarea { max-width: 100%; padding: 8px 11px; border-radius: 8px; font-size: 14px; line-height: 1.4; resize: vertical; }
.kha-fe .kha-remove {
	color: #c0392b; background: none; border: 0; cursor: pointer; font-weight: 600; font-size: .9em; padding: 6px 8px; border-radius: 6px;
	white-space: nowrap;
}
.kha-fe .kha-remove:hover { background: #fdecec; text-decoration: none; }

.kha-fe .kha-rabatt-table { width: auto; margin: 16px 0 0; }
.kha-fe .kha-rabatt-table th { width: auto; padding-right: 16px; }
.kha-fe .kha-rabatt-table td { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.kha-fe .kha-rabatt-table input[type="number"] { width: 110px; }
.kha-fe .kha-rabatt-table .description { display: inline; margin: 0; }

/* ---------- Summen ---------- */
.kha-fe .kha-summe { margin: 20px 0 0; display: flex; justify-content: flex-end; }
.kha-fe .kha-summe table { border-collapse: collapse; min-width: 360px; background: var(--kha-bg); border-radius: 10px; overflow: hidden; }
.kha-fe .kha-summe td { padding: 10px 18px; font-variant-numeric: tabular-nums; }
.kha-fe .kha-summe td.kha-right { text-align: right; font-weight: 600; }
.kha-fe .kha-summe .kha-brutto td {
	border-top: 2px solid var(--kha-blue);
	font-weight: 800; font-size: 1.12em; color: var(--kha-blue);
	padding-top: 12px; padding-bottom: 12px;
}

/* ---------- Ausgabe-Buttons (Backend-Klassen .button) ---------- */
.kha-fe .kha-card p { margin: 0 0 14px; }
.kha-fe .button {
	display: inline-flex; align-items: center; justify-content: center;
	padding: 12px 22px; border-radius: 9px; background: #eef2f7; color: var(--kha-blue);
	border: 1px solid #d3dbe6; text-decoration: none; text-align: center; cursor: pointer;
	font-weight: 600; font-size: 15px; transition: background .15s ease, box-shadow .15s ease;
}
.kha-fe .button:hover { background: #e3e9f1; }
.kha-fe .button-primary { background: var(--kha-blue); color: #fff; border-color: var(--kha-blue); box-shadow: 0 2px 8px rgba(0,105,180,.25); }
.kha-fe .button-primary:hover { background: var(--kha-blue-dark); color: #fff; }
.kha-fe label input[type="checkbox"] { width: auto; margin-right: 8px; }

/* ---------- Kopf-Zähler ---------- */
.kha-fe-total {
	display: inline-block; vertical-align: middle; margin-left: 8px;
	min-width: 26px; padding: 2px 9px; border-radius: 999px;
	background: var(--kha-bg); color: var(--kha-muted);
	font-size: .55em; font-weight: 700; line-height: 1.6; text-align: center;
}

/* ---------- Werkzeugleiste (Suche + Filter) ---------- */
.kha-fe-toolbar { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; flex-wrap: wrap; }
.kha-fe-search-wrap { position: relative; flex: 1 1 320px; min-width: 220px; }
.kha-fe-search {
	width: 100%; padding: 11px 14px 11px 40px; border: 1px solid #cdd4de; border-radius: 9px;
	font-size: 15px; background: #fff
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236c7789' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E")
		no-repeat 13px center;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.kha-fe-search:focus { outline: 0; border-color: var(--kha-blue); box-shadow: 0 0 0 3px rgba(0,105,180,.15); }
.kha-fe-filter { padding: 11px 14px; border: 1px solid #cdd4de; border-radius: 9px; font-size: 15px; background: #fff; min-width: 200px; }
.kha-fe-filter:focus { outline: 0; border-color: var(--kha-blue); box-shadow: 0 0 0 3px rgba(0,105,180,.15); }
.kha-fe-resultinfo { margin-left: auto; color: var(--kha-muted); font-size: .9em; white-space: nowrap; }

/* ---------- Objekt-Badge ---------- */
.kha-fe-badge {
	display: inline-flex; align-items: center; gap: 8px;
	padding: 4px 11px 4px 9px; border: 1px solid var(--kha-line); border-radius: 999px;
	background: #fbfcfe; font-size: .9em; font-weight: 600; white-space: nowrap;
}
.kha-fe-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px rgba(0,0,0,.1) inset; flex: none; }

/* Nummer + Empfänger als Links */
.kha-fe-nr a { color: var(--kha-ink); text-decoration: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.kha-fe-nr a:hover { color: var(--kha-blue); }
.kha-fe-empf a { color: var(--kha-ink); text-decoration: none; font-weight: 600; }
.kha-fe-empf a:hover { color: var(--kha-blue); text-decoration: underline; }
.kha-fe-datum { color: var(--kha-muted); white-space: nowrap; }

/* Status-Kennzeichen */
.kha-fe-status {
	display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px;
	background: #fff4e5; color: #b3600a; border: 1px solid #f6dcb8;
	font-size: .72em; font-weight: 700; vertical-align: middle; text-transform: uppercase; letter-spacing: .03em;
}
.kha-fe-noresult { text-align: center; color: var(--kha-muted); padding: 26px 10px !important; }

/* ---------- Responsiv ---------- */
@media (max-width: 782px) {
	.kha-fe-toolbar { flex-direction: column; align-items: stretch; }
	.kha-fe-resultinfo { margin-left: 0; }
	.kha-fe-filter { min-width: 0; width: 100%; }
	.kha-card { padding: 20px 18px; }
	.kha-fe .form-table th { width: auto; display: block; padding: 10px 0 2px; }
	.kha-fe .form-table td { display: block; padding: 0 0 6px; }
	.kha-fe .form-table tr + tr th, .kha-fe .form-table tr + tr td { border-top: 0; }
	.kha-fe-head { flex-direction: column; align-items: stretch; }
	.kha-fe-head .kha-fe-btn { width: 100%; }
	.kha-fe .kha-add-row { flex-direction: column; }
	.kha-fe .kha-add-row select { min-width: 0; width: 100%; }
	.kha-fe-table thead { display: none; }
	.kha-fe-table, .kha-fe-table tbody, .kha-fe-table tr, .kha-fe-table td { display: block; width: 100%; }
	.kha-fe-table tr { padding: 12px 14px; }
	.kha-fe-table td { padding: 4px 0; text-align: left !important; }
	.kha-fe-actions { padding-top: 10px !important; }
	.kha-fe-actions .kha-fe-link:first-child { margin-left: 0; }
	.kha-fe .kha-summe table { min-width: 0; width: 100%; }
	.kha-fe .kha-positionen { min-width: 620px; }
}
