:root {
  /* Typography */
  --kf-font-family-base:
    "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --kf-font-family-heading: "Playfair Display", "Georgia", serif;
  --kf-font-size-sm: 0.875rem;
  --kf-font-size-base: 1rem;
  --kf-font-size-lg: 1.125rem;
  --kf-font-size-xl: 1.75rem;

  /* Color Palette — Professional Sage Green */
  --kf-color-background: #f3f5f0;
  --kf-color-surface: #fafcf8;
  --kf-color-surface-alt: #f0f4ec;
  --kf-color-border: rgba(30, 58, 14, 0.08);
  --kf-color-text: #1e3a0e;
  --kf-color-text-muted: rgba(30, 58, 14, 0.7);
  --kf-color-primary: #2d5016;
  --kf-color-primary-contrast: #ffffff;
  --kf-color-secondary: #457628;
  --kf-color-accent: #d4af37;
  --kf-color-success: #3a9b69;
  --kf-color-warning: #e6a23d;
  --kf-color-danger: #cf4b47;
  --kf-color-info: #487eb8;

  /* Elevation & Radius */
  --kf-radius-sm: 8px;
  --kf-radius-md: 16px;
  --kf-radius-lg: 24px;
  --kf-shadow-sm: 0 4px 12px rgba(20, 16, 12, 0.08);
  --kf-shadow-md: 0 12px 32px rgba(20, 16, 12, 0.12);
  --kf-shadow-lg: 0 24px 48px rgba(20, 16, 12, 0.14);

  /* Spacing */
  --kf-space-2xs: 0.25rem;
  --kf-space-xs: 0.5rem;
  --kf-space-sm: 0.75rem;
  --kf-space-md: 1rem;
  --kf-space-lg: 1.5rem;
  --kf-space-xl: 2rem;
  --kf-space-2xl: 3rem;

  /* Component Tokens */
  --kf-banner-height: clamp(88px, 12vh, 128px);
  --kf-sidebar-width: 280px;
  --kf-transition-base: 180ms ease;
}

body {
  font-family: var(--kf-font-family-base);
  font-size: var(--kf-font-size-base);
  background: var(--kf-color-background);
  color: var(--kf-color-text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--kf-font-family-heading);
  letter-spacing: 0.02em;
}

/* Apply heading/text colors only within the authenticated app layout.
   Public pages (EmptyLayout) use their own CSS with appropriate colors
   for dark-background hero/header sections.  */
/* Headings in the authenticated layout use the theme's text color.
   Gradient page-headers override this naturally via container color. */
.mud-layout h1,
.mud-layout h2,
.mud-layout h3,
.mud-layout h4,
.mud-layout h5,
.mud-layout h6 {
  color: var(--kf-color-text);
}

/* Inside gradient page-header banners, all text inherits the container's
   white color instead of the default theme text color. */
.page-header .mud-typography {
  color: inherit !important;
}

.text-muted {
  color: var(--kf-color-text-muted) !important;
}

.surface {
  background: var(--kf-color-surface);
  border-radius: var(--kf-radius-md);
  box-shadow: var(--kf-shadow-sm);
}

.surface-alt {
  background: var(--kf-color-surface-alt);
  border-radius: var(--kf-radius-md);
  box-shadow: var(--kf-shadow-sm);
}

.badge-kf {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-xs);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: var(--kf-font-size-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(45, 80, 22, 0.12);
  color: var(--kf-color-primary);
}

.btn-kf-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-xs);
  padding: 0.55rem 1.15rem;
  border-radius: var(--kf-radius-sm);
  border: none;
  background: var(--kf-color-primary);
  color: var(--kf-color-primary-contrast);
  font-weight: 600;
  transition:
    transform var(--kf-transition-base),
    box-shadow var(--kf-transition-base);
}

.btn-kf-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--kf-shadow-sm);
}

.btn-kf-primary:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-kf-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-kf-outline {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-xs);
  padding: 0.55rem 1.15rem;
  border-radius: var(--kf-radius-sm);
  border: 1px solid rgba(45, 80, 22, 0.4);
  background: transparent;
  color: var(--kf-color-primary);
  font-weight: 600;
  transition:
    transform var(--kf-transition-base),
    box-shadow var(--kf-transition-base),
    background var(--kf-transition-base);
}

.btn-kf-outline:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--kf-shadow-sm);
  background: rgba(45, 80, 22, 0.08);
}

.btn-kf-outline:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Button variants for pause/resume */
.btn-kf-outline.suggestion-button--warning {
  border-color: rgba(255, 165, 0, 0.4);
  color: #d97706;
}

.btn-kf-outline.suggestion-button--warning:hover:not(:disabled) {
  background: rgba(255, 165, 0, 0.08);
}

.btn-kf-outline.suggestion-button--success {
  border-color: rgba(34, 197, 94, 0.4);
  color: #16a34a;
}

.btn-kf-outline.suggestion-button--success:hover:not(:disabled) {
  background: rgba(34, 197, 94, 0.08);
}

.suggestion-button,
.suggestion-button__content {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-xs);
}

.icon-button {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: 1px solid rgba(30, 58, 14, 0.12);
  background: rgba(30, 58, 14, 0.04);
  color: var(--kf-color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--kf-transition-base),
    transform var(--kf-transition-base),
    box-shadow var(--kf-transition-base),
    border-color var(--kf-transition-base);
}

.icon-button:hover:not(:disabled) {
  background: rgba(45, 80, 22, 0.12);
  transform: translateY(-1px);
  box-shadow: var(--kf-shadow-sm);
}

.icon-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.icon-button--ghost {
  background: transparent;
  border-color: transparent;
}

.icon-button--ghost:hover:not(:disabled) {
  background: rgba(30, 58, 14, 0.08);
}

.icon-button--active {
  border-color: rgba(212, 175, 55, 0.4);
  background: rgba(212, 175, 55, 0.12);
  color: var(--kf-color-accent);
}

.icon-button--compact {
  width: 2rem;
  height: 2rem;
}

.icon-button--danger {
  color: var(--kf-color-danger);
  border-color: rgba(207, 75, 71, 0.28);
  background: rgba(207, 75, 71, 0.08);
}

.icon-button--danger:hover:not(:disabled) {
  background: rgba(207, 75, 71, 0.16);
  box-shadow: 0 8px 24px rgba(207, 75, 71, 0.22);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-xs);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: var(--kf-font-size-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(30, 58, 14, 0.06);
  color: var(--kf-color-text);
}

.status-chip i {
  font-size: 0.85em;
}

.status-chip--success {
  background: rgba(58, 155, 105, 0.16);
  color: var(--kf-color-success);
}

.status-chip--warning {
  background: rgba(230, 162, 61, 0.16);
  color: var(--kf-color-warning);
}

.status-chip--danger {
  background: rgba(207, 75, 71, 0.18);
  color: var(--kf-color-danger);
}

.status-chip--info,
.status-chip--neutral {
  background: rgba(72, 126, 184, 0.12);
  color: var(--kf-color-info);
}

.status-chip--secondary {
  background: rgba(108, 117, 125, 0.12);
  color: #6c757d;
}

.status-chip--alert {
  background: rgba(207, 75, 71, 0.12);
  color: var(--kf-color-danger);
}

.card-kf {
  background: var(--kf-color-surface);
  border-radius: var(--kf-radius-lg);
  box-shadow: var(--kf-shadow-sm);
  border: 1px solid var(--kf-color-border);
  padding: var(--kf-space-lg);
}

.shadow-ring {
  box-shadow:
    0 0 0 1px rgba(45, 80, 22, 0.08),
    var(--kf-shadow-sm);
}

.utility-max-width {
  max-width: 1280px;
  margin: 0 auto;
}

.loading-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--kf-space-sm);
  padding: var(--kf-space-md) var(--kf-space-lg);
  border-radius: var(--kf-radius-lg);
  border: 1px solid var(--kf-color-border);
  box-shadow: var(--kf-shadow-sm);
  color: var(--kf-color-text-muted);
}

.loading-placeholder .spinner-border {
  width: 1.75rem;
  height: 1.75rem;
  color: var(--kf-color-primary);
}

.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--kf-space-md);
  align-items: center;
  justify-content: space-between;
  padding: var(--kf-space-md);
  border-radius: var(--kf-radius-lg);
  border: 1px solid var(--kf-color-border);
  box-shadow: var(--kf-shadow-sm);
}

.search-field {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-sm);
  padding: 0.55rem 0.85rem;
  border-radius: var(--kf-radius-sm);
  border: 1px solid rgba(30, 58, 14, 0.12);
  background: var(--kf-color-surface);
  min-width: min(320px, 100%);
}

.search-field i {
  color: var(--kf-color-text-muted);
}

.search-field input {
  border: none;
  outline: none;
  font-size: var(--kf-font-size-base);
  background: transparent;
  width: 100%;
  color: var(--kf-color-text);
}

.toolbar-meta {
  font-size: var(--kf-font-size-sm);
  color: var(--kf-color-text-muted);
}

.callout {
  display: flex;
  align-items: center;
  gap: var(--kf-space-sm);
  padding: var(--kf-space-sm) var(--kf-space-md);
  border-radius: var(--kf-radius-md);
  border: 1px solid transparent;
  box-shadow: var(--kf-shadow-sm);
  background: var(--kf-color-surface);
}

.callout i {
  font-size: 1.1rem;
}

.callout--info {
  background: rgba(212, 175, 55, 0.12);
  border-color: rgba(212, 175, 55, 0.18);
  color: var(--kf-color-text);
}

.callout--success {
  background: rgba(58, 155, 105, 0.12);
  border-color: rgba(58, 155, 105, 0.18);
  color: var(--kf-color-success);
}

.callout--danger {
  background: rgba(207, 75, 71, 0.12);
  border-color: rgba(207, 75, 71, 0.2);
  color: var(--kf-color-danger);
}

.empty-state {
  display: flex;
  gap: var(--kf-space-md);
  align-items: center;
  padding: var(--kf-space-lg);
  border-radius: var(--kf-radius-lg);
  border: 1px dashed rgba(30, 58, 14, 0.18);
  color: var(--kf-color-text);
  box-shadow: var(--kf-shadow-sm);
}

.empty-state__icon {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(212, 175, 55, 0.14);
  color: var(--kf-color-accent);
  font-size: 1.6rem;
}

.empty-state h3 {
  margin-bottom: var(--kf-space-xs);
  font-size: var(--kf-font-size-lg);
}

.empty-state p {
  margin: 0;
  color: var(--kf-color-text-muted);
}

/* Toast notifications — base design tokens (component styles in MainLayout.razor.css) */
.kf-toast-container {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: var(--kf-space-sm);
}

.kf-toast-container--top-right {
  top: var(--kf-space-lg);
  right: var(--kf-space-lg);
}

.kf-toast-container--top-center {
  top: var(--kf-space-lg);
  left: 50%;
  transform: translateX(-50%);
}

.kf-toast-container--bottom-right {
  bottom: var(--kf-space-lg);
  right: var(--kf-space-lg);
}

.kf-toast-container--bottom-left {
  bottom: var(--kf-space-lg);
  left: var(--kf-space-lg);
}

@media (max-width: 768px) {
  .kf-toast {
    min-width: min(320px, calc(100vw - 2 * var(--kf-space-lg)));
    max-width: calc(100vw - 2 * var(--kf-space-lg));
  }

  .list-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-meta {
    align-self: flex-end;
  }

  .empty-state {
    flex-direction: column;
    align-items: flex-start;
  }
}

.page-container {
  padding: 0 var(--kf-space-lg) var(--kf-space-lg) var(--kf-space-lg);
}

/* Override Bootstrap responsive typography to prevent layout shifts */
h1,
.h1 {
  font-size: 2.5rem;
}
h2,
.h2 {
  font-size: 2rem;
}
h3,
.h3 {
  font-size: 1.75rem;
}
h4,
.h4 {
  font-size: 1.5rem;
}
h5,
.h5 {
  font-size: 1.25rem;
}
h6,
.h6 {
  font-size: 1rem;
}
