/* Keyholder: minimal styles on top of Bootstrap 5 markup. */
.keyholder {
	/* Brand (one place to change for a rename or white label). */
	--kh-brand: #141414;
	--kh-brand-accent: #141414;
	--kh-critical: #b42318;
	--kh-critical-bg: #fef3f2;
	--kh-warn: #b54708;
	--kh-warn-bg: #fffaeb;
	--kh-info: #175cd3;
	--kh-info-bg: #eff8ff;
	--kh-ok: #067647;
	--kh-ok-bg: #ecfdf3;
	--kh-unknown: #5b616e;
	--kh-unknown-bg: #f4f5f7;
	--kh-line: #e4e7ec;
	max-width: 760px;
	margin-inline: auto;
}

.keyholder [hidden] { display: none !important; }
/* Steps swap in and out; keep the browser from shifting the scroll while they do. */
.keyholder { overflow-anchor: none; }
.keyholder [tabindex="-1"]:focus { outline: none; }

.kh-step { padding-block: 0.5rem; scroll-margin-top: 90px; }
.kh-heading { margin-bottom: 0.5rem; }
.kh-report-domain { font-size: 1.5rem; line-height: 1.25; overflow-wrap: anywhere; }
.kh-domain-form { margin-top: 1.25rem; }
.kh-narrow { max-width: 18rem; }
.kh-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Progress */
.kh-progress { text-align: center; padding-block: 2.5rem; }
.kh-spinner {
	width: 44px;
	height: 44px;
	margin: 0 auto 1rem;
	border: 4px solid var(--kh-line);
	border-top-color: var(--kh-brand-accent);
	border-radius: 50%;
	animation: kh-spin 0.9s linear infinite;
}
@keyframes kh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .kh-spinner { animation-duration: 3s; } }
.kh-progress-title { font-size: 1.15rem; color: var(--kh-brand); }
.kh-keyholders .badge.text-bg-secondary { background: var(--kh-brand) !important; }
.keyholder .kh-accent { font-style: italic; }
.kh-progress-list { display: inline-block; text-align: left; color: var(--kh-unknown); margin: 0; }

/* Summary and grade */
.kh-summary { margin-bottom: 1.25rem; }
.kh-summary-top { display: flex; gap: 1.25rem; align-items: center; }
.kh-grades { display: flex; gap: 0.6rem; flex: 0 0 auto; }
.kh-grade {
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-width: 92px;
	min-height: 92px;
	padding: 0.5rem;
	border-radius: 16px;
	border: 3px solid currentColor;
}
.kh-grade-letter { font-size: 2.75rem; font-weight: 700; line-height: 1; }
.kh-grade-label { font-size: 0.72rem; text-align: center; }
.kh-grade-a, .kh-grade-b { color: var(--kh-ok); background: var(--kh-ok-bg); }
.kh-grade-c { color: var(--kh-warn); background: var(--kh-warn-bg); }
.kh-grade-d, .kh-grade-f { color: var(--kh-critical); background: var(--kh-critical-bg); }
.kh-grade-none { color: var(--kh-unknown); background: var(--kh-unknown-bg); }
.kh-domain-name { font-weight: 600; margin-bottom: 0.15rem; word-break: break-all; }
.kh-sentence { font-size: 1.1rem; margin-bottom: 0.4rem; }
.kh-counts { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; margin: 1rem 0 0.5rem; }
.kh-count { padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.9rem; }
.kh-count-critical { background: var(--kh-critical-bg); color: var(--kh-critical); }
.kh-count-warn { background: var(--kh-warn-bg); color: var(--kh-warn); }
.kh-count-info { background: var(--kh-info-bg); color: var(--kh-info); }
.kh-summary-actions { margin-top: 1rem; }

/* Questions */
.kh-q { margin: 0 0 1.5rem; padding: 1rem 1.1rem; border: 1px solid var(--kh-line); border-radius: 10px; }
.kh-q legend { float: left; width: 100%; font-size: 1.05rem; font-weight: 600; margin-bottom: 0.5rem; padding: 0; }
.kh-q legend + * { clear: left; }
.kh-person { margin-bottom: 0.5rem; }
.kh-sub { margin-top: 0.75rem; padding-left: 1rem; border-left: 3px solid var(--kh-line); }

/* Report */
.kh-group { margin-block: 1.5rem; }
.kh-group-title { font-size: 1.25rem; margin-bottom: 0.75rem; }
.kh-group details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 0.5rem; }
.kh-group details > summary::-webkit-details-marker { display: none; }
.kh-group details > summary::after { content: ""; width: 0.55em; height: 0.55em; margin-left: auto; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform 0.15s ease; }
.kh-group details:not([open]) > summary::after { transform: rotate(-45deg); }
.kh-group details:not([open]) > summary { margin-bottom: 0; }
.kh-finding {
	margin-bottom: 0.9rem;
	padding: 0.9rem 1rem 0.6rem;
	border: 1px solid var(--kh-line);
	border-left: 5px solid var(--kh-unknown);
	border-radius: 8px;
}
.kh-finding-critical { border-left-color: var(--kh-critical); }
.kh-finding-warn { border-left-color: var(--kh-warn); }
.kh-finding-info { border-left-color: var(--kh-info); }
.kh-finding-ok { border-left-color: var(--kh-ok); padding-bottom: 0.2rem; }
.kh-finding-title { font-size: 1.05rem; margin-bottom: 0.3rem; }
.kh-label { font-weight: 600; }
.kh-fix ol { margin: 0.25rem 0 0.6rem; padding-left: 1.3rem; }
.kh-who { color: var(--kh-unknown); font-size: 0.95rem; }
.kh-facts-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.6rem 1.25rem; margin: 0; }
.kh-facts-list dt { font-weight: 400; color: var(--kh-unknown); font-size: 0.9rem; }
.kh-facts-list dd { margin: 0; font-weight: 600; }
.kh-facts { margin-block: 1.5rem; }
/* "At a glance": one card per area, tinted by its worst finding (matches the report email). */
.kh-areas { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
@media (min-width: 576px) { .kh-areas { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kh-area { border: 1px solid var(--kh-unknown-bg); background: var(--kh-unknown-bg); border-radius: 12px; padding: 1rem 1.1rem; }
.kh-area-critical { background: var(--kh-critical-bg); border-color: color-mix(in srgb, var(--kh-critical) 25%, transparent); }
.kh-area-warn { background: var(--kh-warn-bg); border-color: color-mix(in srgb, var(--kh-warn) 25%, transparent); }
.kh-area-ok { background: var(--kh-ok-bg); border-color: color-mix(in srgb, var(--kh-ok) 25%, transparent); }
.kh-area-status { margin: 0; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--kh-unknown); }
.kh-area-critical .kh-area-status { color: var(--kh-critical); }
.kh-area-warn .kh-area-status { color: var(--kh-warn); }
.kh-area-ok .kh-area-status { color: var(--kh-ok); }
.kh-area-name { margin: 0.15rem 0 0.35rem; font-size: 1.15rem; font-weight: 700; }
.kh-area-issue { margin: 0 0 0.5rem; font-weight: 600; }
.kh-area-facts { margin: 0; display: grid; gap: 0.3rem; }
.kh-area-facts div { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.9rem; }
.kh-area-facts dt { font-weight: 400; color: var(--kh-unknown); }
.kh-area-facts dd { margin: 0; font-weight: 600; text-align: right; }
.kh-keyholders { margin-block: 2.5rem 1.5rem; }
.kh-table { font-size: 0.95rem; }
.kh-more-qs { margin: 0 0 1.5rem; border: 1px solid var(--kh-line); border-radius: 10px; }
.kh-more-qs > summary { display: block; cursor: pointer; padding: 1rem 2.75rem 1rem 1.1rem; position: relative; list-style: none; }
.kh-more-qs > summary::-webkit-details-marker { display: none; }
.kh-more-qs > summary::after { content: "+"; position: absolute; right: 1.1rem; top: 50%; transform: translateY(-50%); font-size: 1.4rem; line-height: 1; }
.kh-more-qs[open] > summary::after { content: "\2212"; }
.kh-more-qs-title { display: block; font-weight: 600; font-size: 1.1rem; }
.kh-more-qs-sub { display: block; color: var(--kh-unknown); font-size: 0.95rem; }
.kh-more-qs[open] { padding-bottom: 0.25rem; }
.kh-more-qs > .kh-q, .kh-more-qs > div > .kh-q { margin-inline: 1rem; }
.kh-more-qs > p { margin-inline: 1.1rem; }
.kh-system-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.15rem 1rem; margin-bottom: 0.5rem; }
.kh-system { margin-top: 1rem; }
.kh-system-name { font-weight: 600; margin-bottom: 0.5rem; }
.kh-help { margin-block: 1.5rem; scroll-margin-top: 90px; }
.kh-offer { padding: 1.5rem; border: 1px solid var(--kh-brand); border-radius: 0.75rem; }
.kh-offer-eyebrow { margin: 0 0 0.5rem; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }
.kh-offer h3 { margin-bottom: 0.5rem; }
.kh-offer-dk { padding: 0.75rem 1rem; background: rgba(0, 0, 0, 0.04); border-radius: 0.5rem; }
.kh-offer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-top: 1rem; }
.kh-help-form { margin-top: 1rem; }
.kh-help-form textarea { resize: vertical; }
.kh-help-done { margin-top: 1rem; }

/* Waitlist and contact form */
.kh-waitlist { max-width: 680px; }
.kh-waitlist .kh-intro { margin-bottom: 1.75rem; }
.kh-waitlist-done { margin-top: 1rem; }

/* Monitoring page (links from monitoring emails) */
.kh-monitor { max-width: 680px; }
.kh-hq-label { margin-bottom: .5rem; }
.kh-monitor .kh-intro { margin-bottom: 1.5rem; }
.kh-monitor-box { padding: 1.25rem 0; border-top: 1px solid rgba(0, 0, 0, .12); }
.kh-monitor-box h2 { margin-bottom: .5rem; }
.kh-monitor-people li { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; padding: .5rem 0; border-bottom: 1px solid rgba(0, 0, 0, .06); }
.kh-monitor-people li > span:first-child { flex: 1 1 16rem; }
.kh-monitor-status { font-size: .875rem; color: #5b616e; }
.kh-monitor-note { margin: .75rem 0; font-size: .9375rem; }
.kh-monitor-foot { margin-top: 1rem; }
.kh-monitor-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Keyholder HQ (signed in): main column plus a plan sidebar */
.kh-monitor.kh-hq { max-width: 1040px; }
.kh-hq-grid { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
	.kh-hq-grid { grid-template-columns: minmax(0, 1fr) 300px; gap: 3rem; }
	.kh-hq-side { align-self: start; }
}
.kh-hq-domain + .kh-hq-domain { margin-top: 1.5rem; }
.kh-hq-domain-head { display: flex; gap: 1rem; align-items: center; margin-bottom: .75rem; }
.kh-hq-grade.kh-grade { width: 3rem; height: 3rem; min-width: 3rem; min-height: 3rem; padding: 0; border-width: 2px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 700; border-radius: 10px; }
.kh-hq-domain-name { margin: 0; font-weight: 600; font-size: 1.0625rem; }
.kh-hq-meta { margin: 0; font-size: .875rem; color: #5b616e; }
.kh-hq-warn { color: #b42318; font-weight: 600; }
.kh-hq-ok { margin: 0; color: #067647; }
.kh-hq-issues { margin: 0; }
.kh-hq-issue { border-left: 3px solid #d9a400; padding: .5rem .75rem; background: #fffaeb; border-radius: 0 6px 6px 0; }
.kh-hq-issue + .kh-hq-issue { margin-top: .5rem; }
.kh-hq-issue-critical { border-left-color: #b42318; background: #fdf3f2; }
.kh-hq-issue summary { cursor: pointer; }
.kh-hq-issue details p, .kh-hq-issue details ol { margin: .5rem 0 0; font-size: .9375rem; }
.kh-hq-issue-tag { margin-left: .35rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #5b616e; }
.kh-hq-card { padding: 1.25rem; border: 1px solid rgba(0, 0, 0, .12); border-radius: 12px; background: #fff; }
.kh-hq-card + .kh-hq-card { margin-top: 1rem; }
.kh-hq-card .kh-label-mono { margin-bottom: .25rem; }
.kh-hq-card p { font-size: .9375rem; }
.keyholder .kh-hq-card .kh-hq-plan { margin: 0 0 .75rem; font-size: 1.375rem; font-weight: 600; line-height: 1.2; }
.kh-hq-facts { margin: 0 0 1rem; }
.kh-hq-facts > div { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid rgba(0, 0, 0, .06); font-size: .9375rem; }
.kh-hq-facts dt { font-weight: 400; color: #5b616e; }
.kh-hq-facts dd { margin: 0; text-align: right; }
.kh-hq-upgrade { margin: 0 0 1rem; padding: 1rem; background: #f4f3ef; border-radius: 10px; }
.kh-hq-upgrade p:first-child { margin-top: 0; }
.kh-hq-card form.d-inline { display: block !important; }
.kh-hq-link { display: inline-block; font-size: .9375rem; }
.kh-hq-inline { display: flex; gap: .5rem; }
.kh-hq-inline .form-control { min-width: 0; flex: 1 1 auto; }
.kh-hq-inline .btn { flex: 0 0 auto; white-space: nowrap; }
.kh-hq-card hr { margin: 1.25rem 0; opacity: .12; }
.kh-lead { margin-top: 2rem; scroll-margin-top: 90px; scroll-margin-bottom: 24px; }
.kh-report-jump { margin: 0.25rem 0 1.75rem; }
.kh-answer-cta { margin: 0 0 1.75rem; padding: 1rem 1.25rem; border: 1px solid var(--kh-line, #d9d9d4); border-radius: 0.75rem; }
.kh-answer-cta p { margin-bottom: 0.75rem; }
.kh-jump-link { font-weight: 500; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }

/* Saved report page */
.kh-report-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; }
.kh-report-actions { display: flex; gap: 0.5rem; }
.kh-eyebrow { color: var(--kh-brand); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; margin-bottom: 0.25rem; }
.kh-delete { margin-top: 2rem; }

@media (max-width: 575.98px) {
	.kh-summary-top { flex-direction: column; align-items: flex-start; }
	.kh-table { display: block; overflow-x: auto; }
	.kh-domain-form .input-group { flex-direction: column; }
	.kh-domain-form .input-group > * { width: 100%; border-radius: 0.5rem !important; margin-left: 0 !important; }
	.kh-domain-form .input-group > .btn { margin-top: 0.5rem; }
}

@media print {
	.kh-report-actions, .kh-private-note, .kh-delete, .kh-help, .kh-lead { display: none !important; }
	.kh-group details { display: block; }
	.kh-finding { break-inside: avoid; }
}

/* Spinner inside a button while a request runs. */
.kh-spinner { display: inline-block; width: 1em; height: 1em; vertical-align: -0.15em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: kh-spin 0.7s linear infinite; }
@keyframes kh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .kh-spinner { animation-duration: 1.6s; } }
button[aria-busy="true"] { cursor: progress; }

/* Keyholder HQ: where a request stands. */
.kh-hq-status { margin: 0; font-weight: 600; }
