:root {
  --kp-context-color: var(--muted, #64748b);
  --kp-context-size: 11px;
  --kp-context-line-height: 1.3;
}

/* One compact, stable header across every connected KP SYSTEM module. */
.kp-app-header {
  min-height: 58px;
  padding: 8px 16px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  background: var(--blue, #1f4e78) !important;
  color: #fff !important;
}

.kp-app-brand { min-width: max-content; }
.kp-app-brand h1 {
  margin: 0 !important;
  color: #fff !important;
  font-size: 20px !important;
  line-height: 1.1 !important;
  white-space: nowrap;
}
.kp-app-brand small { display:block; margin-top:3px; font-size:10px; color:#dbeafe; }
.kp-app-brand small.warning { color:#fde68a; font-weight:700; }

.kp-header-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  min-width: 0;
}

.kp-user { white-space: nowrap; font-size: 13px; }
.kp-logout {
  min-height: 30px;
  padding: 6px 9px !important;
  border: 1px solid #ffffff42 !important;
  border-radius: 6px !important;
  background: #ffffff18 !important;
  color: #fff !important;
  font-size: 11px !important;
  font-weight: 700 !important;
}

/* Shared navigation for the connected Price Manager workflow. */
.kp-module-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.kp-module-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid #ffffff42;
  border-radius: 6px;
  background: #ffffff18;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.kp-module-nav a:hover { background: #ffffff2b; }
.kp-module-nav a[aria-current="page"] {
  background: #fff;
  color: var(--blue, #1f4e78);
}

@media (max-width: 900px) {
  .kp-app-header { align-items: flex-start !important; flex-direction: column; }
  .kp-header-tools { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .kp-module-nav { justify-content: flex-start; }
  .kp-module-nav a { padding: 6px 8px; font-size: 10px; }
}

/*
 * KP SYSTEM value hierarchy:
 *   kp-primary-value = the value used for the decision
 *   kp-context       = supporting context, source, share or explanation
 * Existing `source` elements inherit the same project-wide convention.
 */
.kp-value-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.kp-primary-value {
  color: inherit;
  font-weight: 700;
}

.kp-context,
.source {
  display: block;
  color: var(--kp-context-color);
  font-size: var(--kp-context-size);
  font-weight: 400;
  line-height: var(--kp-context-line-height);
}

@media (max-width: 900px) {
  :root { --kp-context-size: 10px; }
}
.email-panel {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #b8c4d0;
  border-radius: 8px;
  background: #fff;
}

.email-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 8px;
  align-items: end;
}

.email-editor {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 2fr);
  gap: 10px;
}

.email-editor label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: bold;
}

.email-editor textarea {
  width: 100%;
  resize: vertical;
  padding: 8px;
  border: 1px solid #b8c4d0;
  border-radius: 5px;
  font: inherit;
}

.email-intro,
.email-buttons {
  grid-column: 1 / -1;
}

.email-buttons {
  display: flex;
  gap: 8px;
}

.email-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: bold;
}

.email-meta {
  margin: 10px 0;
  font-size: 12px;
  color: #64748b;
}

.email-frame {
  display: none;
  width: 100%;
  height: 640px;
  border: 1px solid #d8e0e8;
  border-radius: 7px;
  background: #fff;
}

.email-frame.visible {
  display: block;
}

@media (max-width: 900px) {
  .email-controls {
    grid-template-columns: 1fr;
  }

  .email-editor {
    grid-template-columns: 1fr;
  }

  .email-frame {
    height: 560px;
  }
}
