/* ===== tokens (verbatim from public/css/app/tokens.css) ===== */

/*
 * UponAI application design tokens
 *
 * This is the visual source of truth for the authenticated application shell
 * and its shared components. Page styles should consume these variables rather
 * than introduce a second palette, type system, spacing scale, or elevation
 * system.
 */

:root {
  color-scheme: light;

  /* Typography */
  --app-font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --app-font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  /* Type scale, stepped up from the design system's compact defaults so long
     admin sessions stay readable. Ratios between steps are unchanged. */
  --app-text-xs: 0.8125rem;
  --app-text-sm: 0.9375rem;
  --app-text-md: 1.0625rem;
  --app-text-lg: 1.1875rem;
  --app-text-xl: 1.625rem;

  /* Core colors */
  --app-brand: var(--brand-primary-color, #3e6aef);
  --app-brand-hover: color-mix(in srgb, var(--app-brand) 88%, #000);
  --app-brand-soft: color-mix(in srgb, var(--app-brand) 11%, #fff);
  --app-canvas: #f7f8fb;
  --app-surface: #ffffff;
  --app-surface-subtle: #f8fafc;
  --app-surface-hover: #f1f5f9;
  --app-text: #111827;
  --app-text-muted: #64748b;
  --app-border: #e2e8f0;
  --app-border-strong: #cbd5e1;
  --app-on-brand: #ffffff;
  --app-contrast: #111827;
  --app-on-contrast: #ffffff;
  --app-code-surface: #0f172a;
  --app-code-text: #f8fafc;

  /* Semantic colors */
  --app-success: #15803d;
  --app-success-strong: #15803d;
  --app-success-soft: #f0fdf4;
  --app-success-border: #bbf7d0;
  --app-warning: #92400e;
  --app-warning-strong: #b45309;
  --app-warning-soft: #fffbeb;
  --app-warning-border: #fde68a;
  --app-danger: #b91c1c;
  --app-danger-strong: #dc2626;
  --app-danger-soft: #fef2f2;
  --app-danger-border: #fecaca;
  --app-info: #075985;
  --app-info-soft: #f0f9ff;
  --app-info-border: #bae6fd;

  /* Shape, depth, and motion */
  --app-radius-xs: 0.375rem;
  --app-radius-sm: 0.5rem;
  --app-radius-md: 0.625rem;
  --app-radius-lg: 0.75rem;
  --app-radius-pill: 999px;
  --app-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --app-shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.1);
  --app-shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.16);
  --app-overlay: rgba(15, 23, 42, 0.48);
  --app-focus-ring: 0 0 0 3px color-mix(in srgb, var(--app-brand) 16%, transparent);
  --app-transition-fast: 120ms ease;

  /* Layout and controls */
  /* Sized to suit the larger type above. */
  --app-sidebar-width: 284px;
  --app-sidebar-collapsed-width: 68px;
  --app-topbar-height: 62px;
  --app-page-gutter: 32px;
  --app-control-height: 40px;
  --app-control-height-sm: 34px;

  /*
   * Compatibility aliases for the existing sidebar. New application
   * components should use the unprefixed visual tokens above.
   */
  --app-nav-brand: var(--app-brand);
  --app-nav-bg: var(--app-surface);
  --app-nav-surface: var(--app-surface-subtle);
  --app-nav-surface-hover: var(--app-surface-hover);
  --app-nav-active: var(--app-brand-soft);
  --app-nav-border: var(--app-border);
  --app-nav-text: var(--app-text);
  --app-nav-muted: var(--app-text-muted);
  --app-nav-shadow: var(--app-shadow-lg);
}

[data-bs-theme="dark"] {
  color-scheme: dark;

  --app-brand-soft: color-mix(in srgb, var(--app-brand) 16%, transparent);
  --app-canvas: #0d1118;
  --app-surface: #11161f;
  --app-surface-subtle: #181e28;
  --app-surface-hover: #202834;
  --app-text: #f1f5f9;
  --app-text-muted: #94a3b8;
  --app-border: #29313d;
  --app-border-strong: #3b4655;
  --app-contrast: #f8fafc;
  --app-on-contrast: #0f172a;
  --app-code-surface: #090d14;
  --app-code-text: #e2e8f0;

  --app-success: #86efac;
  --app-success-strong: #15803d;
  --app-success-soft: rgba(34, 197, 94, 0.1);
  --app-success-border: rgba(34, 197, 94, 0.22);
  --app-warning: #fcd34d;
  --app-warning-strong: #b45309;
  --app-warning-soft: rgba(245, 158, 11, 0.1);
  --app-warning-border: rgba(245, 158, 11, 0.24);
  --app-danger: #fca5a5;
  --app-danger-strong: #f87171;
  --app-danger-soft: rgba(239, 68, 68, 0.1);
  --app-danger-border: rgba(239, 68, 68, 0.24);
  --app-info: #7dd3fc;
  --app-info-soft: rgba(14, 165, 233, 0.1);
  --app-info-border: rgba(14, 165, 233, 0.24);

  --app-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.16);
  --app-shadow-sm: 0 12px 30px rgba(0, 0, 0, 0.28);
  --app-shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.42);
  --app-overlay: rgba(0, 0, 0, 0.62);
}


/* ===== foundation (verbatim from public/css/app/foundation.css) ===== */

/*
 * UponAI authenticated application foundation
 */

body.upon-sidebar-enabled,
body:has(.app-sidebar) {
  color: var(--app-text);
  background: var(--app-canvas);
  font-family: var(--app-font-sans);
  font-size: var(--app-text-md);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.app-sidebar,
.app-topbar,
.app-page,
.app-modal {
  font-family: var(--app-font-sans);
}

.app-page {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 28px var(--app-page-gutter) 48px;
  color: var(--app-text);
}

.app-page__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.app-page__heading {
  min-width: 0;
}

.app-page__eyebrow {
  margin: 0 0 5px;
  color: var(--app-text-muted);
  font-size: var(--app-text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-page__title {
  margin: 0 0 4px;
  color: var(--app-text);
  font-size: var(--app-text-xl);
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.app-page__description {
  max-width: 700px;
  margin: 0;
  color: var(--app-text-muted);
  font-size: var(--app-text-md);
  line-height: 1.55;
}

.app-page__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

:where(.app-page, .app-modal) :focus-visible {
  outline: 2px solid color-mix(in srgb, var(--app-brand) 72%, transparent);
  outline-offset: 2px;
}

@media (max-width: 767.98px) {
  :root {
    --app-page-gutter: 18px;
  }

  .app-page {
    padding-top: 22px;
    padding-bottom: 40px;
  }

  .app-page__header {
    flex-direction: column;
    gap: 12px;
  }

  .app-page__actions {
    width: 100%;
  }
}

@media (max-width: 479.98px) {
  :root {
    --app-page-gutter: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}


/* ===== components (verbatim from public/css/app/components.css) ===== */

/*
 * UponAI shared application components
 *
 * Components in this file are deliberately view-neutral. Feature styles may
 * arrange them, but should not redefine their typography, palette, or states.
 */

/* Buttons */
.app-button {
  display: inline-flex;
  min-height: var(--app-control-height);
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 11px;
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  font-family: inherit;
  font-size: var(--app-text-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition:
    color var(--app-transition-fast),
    background-color var(--app-transition-fast),
    border-color var(--app-transition-fast),
    box-shadow var(--app-transition-fast);
}

.app-button:hover,
.app-button:focus-visible {
  color: var(--app-text);
  background: var(--app-surface-hover);
  border-color: color-mix(in srgb, var(--app-brand) 28%, var(--app-border));
  text-decoration: none;
}

.app-button--primary {
  color: var(--app-on-brand);
  background: var(--app-brand);
  border-color: var(--app-brand);
}

.app-button--primary:hover,
.app-button--primary:focus-visible {
  color: var(--app-on-brand);
  background: var(--app-brand-hover);
  border-color: var(--app-brand-hover);
  box-shadow: var(--app-focus-ring);
}

.app-button--secondary {
  color: var(--app-text);
  background: var(--app-surface);
  border-color: var(--app-border);
}

.app-button--ghost {
  color: var(--app-text-muted);
  background: transparent;
  border-color: transparent;
  font-weight: 550;
}

.app-button--ghost:hover,
.app-button--ghost:focus-visible {
  color: var(--app-text);
  background: var(--app-surface-hover);
  border-color: transparent;
  box-shadow: none;
}

.app-button--contrast {
  color: var(--app-on-contrast);
  background: var(--app-contrast);
  border-color: var(--app-contrast);
  border-radius: var(--app-radius-pill);
  font-weight: 650;
}

.app-button--contrast:hover,
.app-button--contrast:focus-visible {
  color: var(--app-on-contrast);
  background: color-mix(in srgb, var(--app-contrast) 88%, var(--app-surface));
  border-color: color-mix(in srgb, var(--app-contrast) 88%, var(--app-surface));
  box-shadow: var(--app-focus-ring);
}

.app-button--danger {
  color: #fff;
  background: var(--app-danger-strong);
  border-color: var(--app-danger-strong);
}

.app-button--success {
  color: #fff;
  background: var(--app-success-strong);
  border-color: var(--app-success-strong);
}

.app-button--warning {
  color: #fff;
  background: var(--app-warning-strong);
  border-color: var(--app-warning-strong);
}

.app-button--sm {
  min-height: var(--app-control-height-sm);
  padding: 5px 9px;
  font-size: 0.875rem;
}

.app-button:disabled,
.app-button[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

/* Icon-only controls */
.app-icon-button {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  padding: 0;
  color: var(--app-text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--app-radius-xs);
  font-family: inherit;
  font-size: 0.875rem;
  transition:
    color var(--app-transition-fast),
    background-color var(--app-transition-fast),
    border-color var(--app-transition-fast);
}

.app-icon-button:hover,
.app-icon-button:focus-visible {
  color: var(--app-text);
  background: var(--app-surface-hover);
  border-color: var(--app-border);
}

.app-icon-button--success {
  color: var(--app-success);
}

.app-icon-button--danger {
  color: var(--app-danger);
}

.app-icon-button--danger:hover,
.app-icon-button--danger:focus-visible {
  color: var(--app-danger-strong);
}

.app-icon-button:disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Surfaces and toolbars */
.app-surface {
  min-width: 0;
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  box-shadow: var(--app-shadow-xs);
}

.app-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
}

.app-context-chip {
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 32px;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  color: var(--app-text-muted);
  background: var(--app-surface-subtle);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  font-size: 0.875rem;
  font-weight: 550;
  white-space: nowrap;
}

.app-context-chip > i {
  color: var(--app-brand);
}

/* Breadcrumbs */
.app-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  color: var(--app-text-muted);
  font-size: var(--app-text-sm);
  list-style: none;
}

.app-breadcrumb__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.app-breadcrumb__item + .app-breadcrumb__item::before {
  color: var(--app-border-strong);
  content: "/";
}

.app-breadcrumb__item a {
  color: var(--app-text-muted);
  text-decoration: none;
}

.app-breadcrumb__item a:hover,
.app-breadcrumb__item a:focus-visible {
  color: var(--app-text);
  text-decoration: none;
}

.app-breadcrumb__item[aria-current="page"] {
  color: var(--app-text);
  font-weight: 600;
}

/* Sections and statistics */
.app-section {
  min-width: 0;
  padding: 18px;
  color: var(--app-text);
  background: var(--app-surface-subtle);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
}

.app-section__title {
  margin: 0 0 4px;
  color: var(--app-text);
  font-size: var(--app-text-lg);
  font-weight: 650;
  line-height: 1.35;
}

.app-section__description {
  margin: 0;
  color: var(--app-text-muted);
  font-size: var(--app-text-sm);
  line-height: 1.5;
}

.app-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.app-stat {
  min-width: 0;
  padding: 12px;
  color: var(--app-text);
  background: var(--app-surface-subtle);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
}

.app-stat__label {
  overflow: hidden;
  margin: 0;
  color: var(--app-text-muted);
  font-size: var(--app-text-xs);
  font-weight: 650;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.app-stat__value {
  overflow: hidden;
  margin: 4px 0 0;
  color: var(--app-text);
  font-size: var(--app-text-lg);
  font-weight: 650;
  line-height: 1.3;
  text-overflow: ellipsis;
}

/* Search and form controls */
.app-search {
  display: flex;
  width: min(390px, 100%);
  min-height: var(--app-control-height);
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  color: var(--app-text-muted);
  background: var(--app-surface-subtle);
  border: 1px solid transparent;
  border-radius: var(--app-radius-sm);
  transition:
    background-color var(--app-transition-fast),
    border-color var(--app-transition-fast),
    box-shadow var(--app-transition-fast);
}

.app-search:focus-within {
  background: var(--app-surface);
  border-color: color-mix(in srgb, var(--app-brand) 55%, var(--app-border));
  box-shadow: var(--app-focus-ring);
}

.app-search input {
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--app-text);
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: var(--app-text-sm);
}

.app-search input::placeholder {
  color: var(--app-text-muted);
}

.app-input,
.app-select,
.app-textarea {
  width: 100%;
  min-height: var(--app-control-height);
  padding: 7px 10px;
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  font: inherit;
  font-size: var(--app-text-sm);
}

.app-input:focus,
.app-select:focus,
.app-textarea:focus {
  border-color: color-mix(in srgb, var(--app-brand) 55%, var(--app-border));
  box-shadow: var(--app-focus-ring);
  outline: 0;
}

.app-input:disabled,
.app-select:disabled,
.app-textarea:disabled {
  color: var(--app-text-muted);
  background: var(--app-surface-subtle);
  cursor: not-allowed;
  opacity: 0.72;
}

.app-input--bare {
  min-height: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.app-input--bare:focus {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.app-chip-input {
  display: flex;
  width: 100%;
  min-height: var(--app-control-height);
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  cursor: text;
  transition:
    border-color var(--app-transition-fast),
    box-shadow var(--app-transition-fast);
}

.app-chip-input:focus-within {
  border-color: color-mix(in srgb, var(--app-brand) 55%, var(--app-border));
  box-shadow: var(--app-focus-ring);
}

.app-chip-input__tag {
  max-width: 100%;
}

.app-chip-input__remove.app-icon-button {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: inherit;
  border-radius: var(--app-radius-pill);
  font-size: var(--app-text-xs);
}

.app-chip-input__remove.app-icon-button:hover,
.app-chip-input__remove.app-icon-button:focus-visible {
  color: inherit;
  background: color-mix(in srgb, currentColor 12%, transparent);
  border-color: transparent;
}

.app-chip-input__control.app-input {
  width: auto;
  min-width: min(150px, 100%);
  flex: 1 1 150px;
}

.app-field {
  display: grid;
  gap: 6px;
}

.app-field__label {
  margin: 0;
  color: var(--app-text);
  font-size: var(--app-text-sm);
  font-weight: 600;
}

.app-field__help,
.app-field__error {
  margin: 0;
  color: var(--app-text-muted);
  font-size: var(--app-text-xs);
  line-height: 1.45;
}

.app-field__error {
  color: var(--app-danger);
}

.app-input[aria-invalid="true"],
.app-select[aria-invalid="true"],
.app-textarea[aria-invalid="true"] {
  border-color: var(--app-danger-border);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-danger) 12%, transparent);
}

.app-range {
  width: 100%;
  accent-color: var(--app-brand);
  cursor: pointer;
}

.app-range:focus-visible {
  border-radius: var(--app-radius-pill);
  box-shadow: var(--app-focus-ring);
  outline: 0;
}

.app-range:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-check {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--app-text);
  font-size: var(--app-text-sm);
  line-height: 1.45;
}

.app-check input {
  width: 15px;
  height: 15px;
  margin: 2px 0 0;
  accent-color: var(--app-brand);
}

.app-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--app-text);
  font-size: var(--app-text-sm);
  font-weight: 550;
  line-height: 1.4;
}

.app-switch__control {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  margin: 0;
  appearance: none;
  background: var(--app-surface-hover);
  border: 1px solid var(--app-border-strong);
  border-radius: var(--app-radius-pill);
  cursor: pointer;
  transition:
    background-color var(--app-transition-fast),
    border-color var(--app-transition-fast),
    box-shadow var(--app-transition-fast);
}

.app-switch__control::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  content: "";
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 50%;
  box-shadow: var(--app-shadow-xs);
  transition: transform var(--app-transition-fast);
}

.app-switch__control:checked {
  background: var(--app-brand);
  border-color: var(--app-brand);
}

.app-switch__control:checked::after {
  transform: translateX(18px);
}

.app-switch__control:focus-visible {
  box-shadow: var(--app-focus-ring);
  outline: 0;
}

.app-switch__control:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-switch:has(.app-switch__control:disabled) {
  color: var(--app-text-muted);
  cursor: not-allowed;
}

/* Tables */
.app-table-wrap {
  overflow-x: auto;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  box-shadow: var(--app-shadow-xs);
}

.app-table-wrap--flush {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.app-table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  color: var(--app-text);
  font-size: var(--app-text-sm);
}

.app-table thead th {
  padding: 10px 14px;
  color: var(--app-text-muted);
  background: var(--app-surface-subtle);
  border-bottom: 1px solid var(--app-border);
  font-size: 0.78125rem;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.app-table tbody td {
  padding: 12px 14px;
  color: var(--app-text);
  background: transparent;
  border-bottom: 1px solid var(--app-border);
  vertical-align: middle;
}

.app-table tbody tr:last-child td {
  border-bottom: 0;
}

.app-table tbody tr:hover td {
  background: color-mix(in srgb, var(--app-brand-soft) 32%, transparent);
}

.app-table tbody tr:focus-visible {
  outline: 0;
}

.app-table tbody tr:focus-visible td {
  background: var(--app-brand-soft);
  box-shadow:
    inset 0 2px 0 color-mix(in srgb, var(--app-brand) 62%, transparent),
    inset 0 -2px 0 color-mix(in srgb, var(--app-brand) 62%, transparent);
}

.app-table__primary {
  display: block;
  overflow: hidden;
  color: var(--app-text);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-table__secondary {
  display: block;
  margin-top: 2px;
  color: var(--app-text-muted);
  font-size: 0.84375rem;
}

.app-table__number {
  font-variant-numeric: tabular-nums;
  text-align: right !important;
  white-space: nowrap;
}

.app-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin: 0;
  padding: 12px;
  list-style: none;
  border-top: 1px solid var(--app-border);
}

.app-pagination .page-link {
  display: grid;
  min-width: var(--app-control-height-sm);
  min-height: var(--app-control-height-sm);
  place-items: center;
  padding: 5px 8px;
  color: var(--app-text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--app-radius-xs);
  font-size: var(--app-text-sm);
  text-decoration: none;
}

.app-pagination .page-link:hover,
.app-pagination .page-link:focus-visible {
  color: var(--app-text);
  background: var(--app-surface-hover);
  border-color: var(--app-border);
}

.app-pagination .active .page-link {
  color: var(--app-on-brand);
  background: var(--app-brand);
  border-color: var(--app-brand);
}

.app-pagination .disabled .page-link {
  opacity: 0.45;
  pointer-events: none;
}

/* Status and feedback */
.app-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  color: var(--app-text-muted);
  background: var(--app-surface-subtle);
  border: 1px solid transparent;
  border-radius: var(--app-radius-pill);
  font-size: var(--app-text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.app-status--dot::before {
  width: 5px;
  height: 5px;
  content: "";
  background: currentColor;
  border-radius: 50%;
}

.app-status--success {
  color: var(--app-success);
  background: var(--app-success-soft);
  border-color: var(--app-success-border);
}

.app-status--warning {
  color: var(--app-warning);
  background: var(--app-warning-soft);
  border-color: var(--app-warning-border);
}

.app-status--danger {
  color: var(--app-danger);
  background: var(--app-danger-soft);
  border-color: var(--app-danger-border);
}

.app-status--info {
  color: var(--app-info);
  background: var(--app-info-soft);
  border-color: var(--app-info-border);
}

.app-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  color: var(--app-text-muted);
  background: var(--app-surface-subtle);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-pill);
  font-size: 0.78125rem;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.app-badge:hover {
  color: inherit;
  text-decoration: none;
}

.app-badge--brand {
  color: color-mix(in srgb, var(--app-brand) 82%, #111827);
  background: var(--app-brand-soft);
  border-color: color-mix(in srgb, var(--app-brand) 24%, var(--app-border));
}

[data-bs-theme="dark"] .app-badge--brand {
  color: color-mix(in srgb, var(--app-brand) 55%, #fff);
}

.app-badge--success {
  color: var(--app-success);
  background: var(--app-success-soft);
  border-color: var(--app-success-border);
}

.app-badge--warning {
  color: var(--app-warning);
  background: var(--app-warning-soft);
  border-color: var(--app-warning-border);
}

.app-badge--danger {
  color: var(--app-danger);
  background: var(--app-danger-soft);
  border-color: var(--app-danger-border);
}

.app-badge--info {
  color: var(--app-info);
  background: var(--app-info-soft);
  border-color: var(--app-info-border);
}

.app-badge--neutral {
  color: var(--app-text-muted);
  background: var(--app-surface-subtle);
  border-color: var(--app-border);
}

.app-badge--wrap {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: left;
  white-space: normal;
}

.app-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: var(--app-radius-md);
  font-size: var(--app-text-sm);
  line-height: 1.5;
}

.app-alert--danger {
  color: var(--app-danger);
  background: var(--app-danger-soft);
  border-color: var(--app-danger-border);
}

.app-alert--warning {
  color: var(--app-warning);
  background: var(--app-warning-soft);
  border-color: var(--app-warning-border);
}

.app-alert--info {
  color: var(--app-info);
  background: var(--app-info-soft);
  border-color: var(--app-info-border);
}

.app-alert--success {
  color: var(--app-success);
  background: var(--app-success-soft);
  border-color: var(--app-success-border);
}

.app-alert--neutral {
  color: var(--app-text-muted);
  background: var(--app-surface-subtle);
  border-color: var(--app-border);
}

.app-empty-state {
  display: grid;
  min-height: 280px;
  place-items: center;
  align-content: center;
  padding: 32px;
  color: var(--app-text);
  text-align: center;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
}

.app-empty-state--compact {
  min-height: 0;
  padding: 28px 18px;
  color: var(--app-text-muted);
  border: 0;
  border-radius: 0;
}

.app-empty-state__icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 12px;
  place-items: center;
  color: var(--app-brand);
  background: var(--app-brand-soft);
  border-radius: var(--app-radius-md);
  font-size: 1.375rem;
}

.app-empty-state--compact .app-empty-state__icon {
  width: auto;
  height: auto;
  margin-bottom: 7px;
  color: inherit;
  background: transparent;
  font-size: 1.375rem;
  opacity: 0.7;
}

.app-empty-state h2 {
  margin: 0 0 5px;
  font-size: 1.0625rem;
  font-weight: 650;
}

.app-empty-state p {
  margin: 0;
  color: var(--app-text-muted);
  font-size: var(--app-text-sm);
}

.app-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--app-text-muted);
  font-size: var(--app-text-sm);
}

.app-loading__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, var(--app-brand) 22%, var(--app-border));
  border-top-color: var(--app-brand);
  border-radius: 50%;
  animation: app-spin 700ms linear infinite;
}

.app-skeleton {
  min-height: 12px;
  background:
    linear-gradient(
      90deg,
      var(--app-surface-subtle) 20%,
      var(--app-surface-hover) 38%,
      var(--app-surface-subtle) 56%
    );
  background-size: 220% 100%;
  border-radius: var(--app-radius-xs);
  animation: app-skeleton 1.35s ease infinite;
}

@keyframes app-spin {
  to { transform: rotate(360deg); }
}

@keyframes app-skeleton {
  to { background-position-x: -220%; }
}

/* Menus and overlays */
.app-tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--app-border);
}

.app-tab {
  flex: 0 0 auto;
  margin-bottom: -1px;
  padding: 8px 12px;
  color: var(--app-text-muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  font: inherit;
  font-size: var(--app-text-sm);
  font-weight: 600;
  white-space: nowrap;
}

.app-tab:hover,
.app-tab:focus-visible {
  color: var(--app-text);
}

.app-tab.is-active,
.app-tab[aria-selected="true"] {
  color: var(--app-brand);
  border-bottom-color: var(--app-brand);
}

.app-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: var(--app-overlay);
}

.app-page .dropdown-menu,
.app-modal .dropdown-menu {
  min-width: 210px;
  padding: 5px;
  color: var(--app-text);
  background: var(--app-surface);
  border-color: var(--app-border);
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow-sm);
}

.app-page .dropdown-item,
.app-modal .dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: var(--app-radius-xs);
  font-size: var(--app-text-sm);
}

.app-page .dropdown-item i,
.app-modal .dropdown-item i {
  width: 16px;
  color: var(--app-text-muted);
  text-align: center;
}

.app-page .dropdown-item.text-danger i,
.app-modal .dropdown-item.text-danger i {
  color: inherit;
}

.app-modal .modal-content {
  color: var(--app-text);
  background: var(--app-surface);
  border-color: var(--app-border);
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-lg);
}

.app-modal .modal-header,
.app-modal .modal-footer {
  border-color: var(--app-border);
}

.app-modal .form-control,
.app-modal .form-select {
  color: var(--app-text);
  background-color: var(--app-surface);
  border-color: var(--app-border);
  border-radius: var(--app-radius-sm);
  font-family: inherit;
  font-size: var(--app-text-sm);
}

.app-drawer.offcanvas {
  color: var(--app-text);
  background: var(--app-surface);
  border-color: var(--app-border);
  box-shadow: var(--app-shadow-lg);
}

.app-drawer .offcanvas-header {
  border-bottom: 1px solid var(--app-border);
}

.app-drawer .offcanvas-title {
  color: var(--app-text);
  font-size: var(--app-text-lg);
  font-weight: 650;
}

.app-tooltip.tooltip {
  font-family: var(--app-font-sans);
}

.app-toast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  width: min(380px, calc(100vw - 28px));
  padding: 11px 12px;
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-color: var(--app-border);
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow-sm);
}

.app-toast-stack {
  position: fixed;
  top: calc(var(--app-topbar-height) + 14px);
  right: 14px;
  z-index: 1100;
  display: grid;
  justify-items: end;
  gap: 8px;
  pointer-events: none;
}

.app-toast-stack > * {
  pointer-events: auto;
}

.app-toast__icon {
  margin-top: 1px;
}

.app-toast__content {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.app-toast__title {
  color: currentColor;
  font-size: var(--app-text-sm);
  font-weight: 650;
}

.app-toast__message {
  color: currentColor;
  font-size: var(--app-text-xs);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.app-toast__close {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  padding: 0;
  color: currentColor;
  background: transparent;
  border: 0;
  border-radius: var(--app-radius-xs);
  opacity: 0.7;
}

.app-toast__close:hover,
.app-toast__close:focus-visible {
  background: color-mix(in srgb, currentColor 10%, transparent);
  opacity: 1;
}

.app-toast--success {
  color: var(--app-success);
  background: var(--app-success-soft);
  border-color: var(--app-success-border);
}

.app-toast--warning {
  color: var(--app-warning);
  background: var(--app-warning-soft);
  border-color: var(--app-warning-border);
}

.app-toast--danger {
  color: var(--app-danger);
  background: var(--app-danger-soft);
  border-color: var(--app-danger-border);
}

.app-toast--info {
  color: var(--app-info);
  background: var(--app-info-soft);
  border-color: var(--app-info-border);
}

@media (max-width: 767.98px) {
  .app-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .app-search {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-button,
  .app-icon-button,
  .app-search {
    transition: none;
  }

  .app-loading__spinner,
  .app-skeleton {
    animation: none;
  }
}
