.kp-reports {
  --report-border: var(--line, #cbdcd5);
  --report-paper: var(--paper, #fcfefe);
  --report-muted: var(--secondary, #586f70);
  --report-accent: var(--green, #216c60);
  --report-fill: var(--accent-wash, #e1efe9);
  --report-error: #902f38;
  position: fixed;
  inset: 0;
  width: min(900px, calc(100% - 32px));
  max-width: none;
  max-height: min(820px, calc(100% - 48px));
  max-height: min(820px, calc(100dvh - 48px));
  overflow: auto;
  overscroll-behavior: contain;
  margin: auto;
  padding: 0;
  border: 1px solid var(--report-border);
  border-radius: 20px;
  background: var(--report-paper);
  color: var(--ink, #193c43);
  box-shadow: 0 18px 80px #192c3455;
}

.kp-reports::backdrop { background: #152a2a64; }
[data-theme='dark'] .kp-reports { --report-error: #ffb5ba; }

.kp-reports-panel { min-height: min(460px, calc(100dvh - 52px)); }
.kp-reports-header {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--report-border);
  background: var(--report-paper);
}

.kp-reports-header h2 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.6rem); line-height: 1.2; }
.kp-reports-main { padding: 20px 26px 28px; }
.kp-reports h3, .kp-reports p, .kp-report-title { overflow-wrap: anywhere; }

.kp-report-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  border: 1px solid var(--report-border);
  border-radius: 10px;
  background: var(--report-paper);
  color: var(--report-accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.kp-report-control:hover:not(:disabled) { background: var(--report-fill); text-decoration: none; }
.kp-report-control:disabled { opacity: 1; background: var(--report-fill); color: var(--report-muted); }
.kp-report-control.kp-report-primary { background: var(--send, #1e514b); color: var(--send-text, #fff); border-color: transparent; }
.kp-report-control.kp-report-primary:hover:not(:disabled) { background: var(--send-hover, #173f3b); }
.kp-report-control.kp-report-delete { color: var(--report-error); }
.kp-reports .kp-report-control:disabled { background: var(--report-fill); color: var(--report-muted); border-color: var(--report-border); }
.kp-report-control:active:not(:disabled) { box-shadow: inset 0 2px 5px var(--glass-depth); }
.kp-reports :is(button, a, input, summary, [tabindex]):focus-visible,
.response-tools .kp-report-save:focus-visible { outline: 2px solid var(--focus, #216c60); outline-offset: 3px; }

.kp-reports-search { display: flex; gap: 8px; margin-bottom: 14px; }
.kp-reports-search input {
  min-width: 0;
  min-height: 44px;
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--report-border);
  border-radius: 10px;
  background: var(--report-paper);
  color: inherit;
  font: inherit;
  font-size: 1rem;
}

.kp-reports-search input::placeholder { color: var(--report-muted); opacity: 1; }
.kp-report-list-item {
  padding: 8px 0 13px;
  border-top: 1px solid var(--report-border);
}

.kp-report-list-item h3 { margin: 0; font-size: 1rem; }
.kp-report-title {
  min-height: 44px;
  padding: 6px 8px;
  margin-left: -8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  font-weight: 680;
}

.kp-report-title:hover { background: var(--report-fill); color: var(--report-accent); }
.kp-report-meta { margin: 0; color: var(--report-muted); font-size: .875rem; }
.kp-reports-empty { padding: 32px 4px; }
.kp-reports-empty h3 { margin: 0 0 4px; }
.kp-reports-empty p { margin: 0; color: var(--report-muted); }
.kp-reports-more, .kp-reports-retry { margin-top: 12px; }

.kp-reports-status { margin: 10px 26px 0; color: var(--report-muted); font-size: .875rem; }
.kp-reports-status:empty { margin: 0; }
.kp-reports-status.kp-reports-error { color: var(--report-error); }
.kp-reports-back { margin-bottom: 18px; }
.kp-reports-undo { padding: 10px 26px; border-bottom: 1px solid var(--report-border); background: var(--report-fill); }
.kp-reports-undo[hidden] { display: none; }
.kp-reports-undo-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kp-reports-undo-row + .kp-reports-undo-row { margin-top: 6px; }

.kp-report-detail { max-width: 800px; margin: auto; }
.kp-report-detail > h3 { margin: 0 0 6px; font-size: clamp(1.45rem, 4vw, 2.15rem); line-height: 1.2; }
.kp-report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 22px; }
.kp-report-question { margin: 0 0 16px; color: var(--report-muted); font-size: 1.02rem; }
.kp-report-detail > .message-body { margin: 0 0 20px; color: inherit; }
.kp-report-section { margin: 20px 0 0; padding-top: 14px; border-top: 1px solid var(--report-border); }
.kp-report-section h3 { margin: 0 0 8px; font-size: 1rem; }
.kp-report-section a { color: var(--report-accent); }
.kp-report-section ul, .kp-report-section ol { padding-left: 1.25em; }
.kp-report-section blockquote { margin: 4px 0 0; padding: 8px 12px; border-left: 2px solid var(--report-border); white-space: pre-wrap; }
.kp-report-sources > li { padding: 6px 0; }
.kp-report-conflict { margin: 0 0 14px; padding: 12px; background: var(--report-fill); border-radius: 8px; }
.kp-report-conflict ul:last-child, .kp-report-conflict p:last-child { margin-bottom: 0; }
.kp-report-disclosure { min-width: 0; }
.kp-report-disclosure > summary { min-height: 44px; padding: 10px 0; color: var(--report-accent); cursor: pointer; }
.kp-report-tree { margin: 0; padding-left: 18px; border-left: 1px solid var(--report-border); }
.kp-report-tree > li { margin: 8px 0; }
.kp-report-tree p { margin: 4px 0 8px; }

.kp-report-chart {
  min-width: 0;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--report-border);
  border-radius: 12px;
}

.kp-report-chart figcaption { margin-bottom: 8px; font-weight: 680; }
.kp-report-overflow { max-width: 100%; overflow: auto; overscroll-behavior-inline: contain; }
.kp-report-overflow svg { display: block; width: 100%; height: auto; min-width: 570px; background: #f8fcf9; border-radius: 8px; }
.kp-report-overflow table { width: 100%; border-collapse: collapse; text-align: left; font-size: .875rem; }
.kp-report-overflow :is(td, th) { padding: 8px; border-bottom: 1px solid var(--report-border); white-space: nowrap; }
.kp-report-overflow th { background: var(--report-fill); }

.response-tools .kp-report-save {
  min-height: 44px;
  padding: 6px 4px;
  color: var(--green, #216c60);
  background: transparent;
}

.response-tools .kp-report-save:disabled { color: var(--secondary, #586f70); }
.kp-report-save-error { margin: 0; font-size: 13px; color: var(--secondary, #586f70); }

.kp-reports-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 550px) {
  .kp-reports { width: calc(100% - 24px); max-height: calc(100dvh - 24px); border-radius: 16px; }
  .kp-reports-header { padding: 12px 16px; }
  .kp-reports-main { padding: 16px; }
  .kp-reports-status { margin-inline: 16px; }
  .kp-reports-undo { padding-inline: 16px; }
  .kp-report-actions { margin-block: 14px 18px; }
  .kp-report-chart { padding: 10px; }
}

@media (forced-colors: active) {
  .kp-reports :is(.kp-report-control, .kp-report-title) { color: ButtonText; border: 1px solid ButtonText; }
  .kp-reports :is(button, a, input, summary, [tabindex]):focus-visible { outline-color: Highlight; }
}
