:root,
[data-theme="light"] {
  color-scheme: light;

  --fm-primary: #14532d;
  --fm-primary-hover: #166534;
  --fm-primary-soft: #dcfce7;
  --fm-primary-foreground: #ffffff;

  --fm-background: #f5f7fa;
  --fm-surface: #ffffff;
  --fm-surface-elevated: #ffffff;
  --fm-surface-muted: #f8fafc;

  --fm-border: #e2e8f0;
  --fm-border-subtle: #eef2f7;

  --fm-text: #0f172a;
  --fm-text-secondary: #334155;
  --fm-text-muted: #64748b;
  --fm-text-inverse: #f8fafc;

  --fm-success: #16a34a;
  --fm-success-soft: #dcfce7;
  --fm-warning: #d97706;
  --fm-warning-soft: #fef3c7;
  --fm-danger: #dc2626;
  --fm-danger-soft: #fee2e2;
  --fm-info: #2563eb;
  --fm-info-soft: #dbeafe;

  --fm-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --fm-shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --fm-shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.12);

  --fm-space-1: 4px;
  --fm-space-2: 8px;
  --fm-space-3: 12px;
  --fm-space-4: 16px;
  --fm-space-5: 20px;
  --fm-space-6: 24px;
  --fm-space-8: 32px;
  --fm-space-10: 40px;
  --fm-space-12: 48px;

  --fm-radius-sm: 6px;
  --fm-radius-md: 8px;
  --fm-radius-lg: 12px;
  --fm-radius-xl: 16px;
  --fm-radius-2xl: 20px;

  --fm-font: "Manrope", "Segoe UI", Helvetica, Arial, sans-serif;
  --fm-sidebar-width: 248px;
  --fm-sidebar-collapsed: 72px;
  --fm-header-height: 64px;
  --fm-tabbar-height: 56px;
  --fm-focus-ring: 0 0 0 3px rgba(22, 163, 74, 0.28);
}

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

  --fm-primary: #22c55e;
  --fm-primary-hover: #4ade80;
  --fm-primary-soft: rgba(34, 197, 94, 0.16);
  --fm-primary-foreground: #052e16;

  --fm-background: #0b1220;
  --fm-surface: #111827;
  --fm-surface-elevated: #1a2333;
  --fm-surface-muted: #151d2b;

  --fm-border: #243044;
  --fm-border-subtle: #1c2638;

  --fm-text: #e5eef9;
  --fm-text-secondary: #cbd5e1;
  --fm-text-muted: #94a3b8;
  --fm-text-inverse: #0f172a;

  --fm-success: #4ade80;
  --fm-success-soft: rgba(74, 222, 128, 0.14);
  --fm-warning: #fbbf24;
  --fm-warning-soft: rgba(251, 191, 36, 0.14);
  --fm-danger: #f87171;
  --fm-danger-soft: rgba(248, 113, 113, 0.14);
  --fm-info: #60a5fa;
  --fm-info-soft: rgba(96, 165, 250, 0.14);

  --fm-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --fm-shadow-md: 0 10px 28px rgba(0, 0, 0, 0.4);
  --fm-shadow-lg: 0 22px 56px rgba(0, 0, 0, 0.5);
  --fm-focus-ring: 0 0 0 3px rgba(34, 197, 94, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html[data-theme] body,
html[data-theme] #root {
  background: var(--fm-background);
  color: var(--fm-text);
  font-family: var(--fm-font);
}

.AdminAppShell {
  background: var(--fm-background) !important;
  color: var(--fm-text);
}

.AdminAppShell-main {
  background: var(--fm-background);
}

.Container.IMSidebarWidget.sidebarSolid,
.Container.sidebarSolid {
  background: var(--fm-surface) !important;
  border-right: 1px solid var(--fm-border) !important;
  box-shadow: none !important;
}

.Container.IMSAppHeaderWidget.appHeaderToolbar,
.Container.IMSAppHeaderWidget.glassPanel.xad {
  background: var(--fm-surface) !important;
  border-bottom: 1px solid var(--fm-border) !important;
  box-shadow: var(--fm-shadow-sm) !important;
}

.headerSearchForm {
  background: var(--fm-surface-muted) !important;
  border-color: var(--fm-border) !important;
}

.headerSearchInput {
  color: var(--fm-text) !important;
}

.headerSearchKbd {
  background: var(--fm-surface) !important;
  border-color: var(--fm-border) !important;
  color: var(--fm-text-muted) !important;
}

.headerIconBtn {
  color: var(--fm-text-secondary) !important;
}

.headerIconBtn:hover,
.headerIconBtn.isOpen {
  background: var(--fm-surface-muted) !important;
  color: var(--fm-text) !important;
}

.headerSettingsMenu {
  background: var(--fm-surface-elevated) !important;
  border-color: var(--fm-border) !important;
  box-shadow: var(--fm-shadow-md) !important;
  color: var(--fm-text);
}

.headerSettingsMenuTitle,
.headerSettingsItem {
  color: var(--fm-text) !important;
}

.headerSettingsItem:hover {
  background: var(--fm-surface-muted) !important;
}

.TextButton.navItem,
.TextButton.navActive {
  color: var(--fm-text-secondary) !important;
}

.TextButton.navActive {
  background: var(--fm-primary-soft) !important;
  color: var(--fm-primary) !important;
}

.TextButton.navItem:hover {
  background: var(--fm-surface-muted) !important;
  color: var(--fm-text) !important;
}

.sidebarSectionToggle,
.sidebarNavLabel {
  color: var(--fm-text-muted) !important;
}

/* Feedback kit */
.fmSkeleton {
  background: linear-gradient(
    90deg,
    var(--fm-surface-muted) 0%,
    var(--fm-border-subtle) 45%,
    var(--fm-surface-muted) 90%
  );
  background-size: 200% 100%;
  animation: fmSkeletonShimmer 1.35s ease-in-out infinite;
  border-radius: var(--fm-radius-md);
}

.fmSkeletonLine {
  height: 12px;
  margin-bottom: 10px;
}

.fmSkeletonLine:last-child {
  margin-bottom: 0;
  width: 62%;
}

.fmSkeletonCard {
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-lg);
  background: var(--fm-surface);
  padding: var(--fm-space-4);
}

.fmSkeletonRow {
  display: grid;
  grid-template-columns: 40px 1.4fr 1fr 0.8fr 72px;
  gap: var(--fm-space-3);
  align-items: center;
  padding: var(--fm-space-3) 0;
  border-bottom: 1px solid var(--fm-border-subtle);
}

@keyframes fmSkeletonShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.fmStateCard {
  align-items: center;
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-xl);
  box-shadow: var(--fm-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--fm-space-3);
  justify-content: center;
  margin: var(--fm-space-6) auto;
  max-width: 440px;
  padding: var(--fm-space-8) var(--fm-space-6);
  text-align: center;
}

.fmStateIcon {
  align-items: center;
  border-radius: 999px;
  display: flex;
  height: 56px;
  justify-content: center;
  width: 56px;
}

.fmStateIcon.isError {
  background: var(--fm-danger-soft);
  color: var(--fm-danger);
}

.fmStateIcon.isEmpty {
  background: var(--fm-primary-soft);
  color: var(--fm-primary);
}

.fmStateIcon.isNetwork {
  background: var(--fm-warning-soft);
  color: var(--fm-warning);
}

.fmStateTitle {
  color: var(--fm-text);
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.fmStateMessage {
  color: var(--fm-text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.fmStateActions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--fm-space-2);
  justify-content: center;
  margin-top: var(--fm-space-2);
}

.fmBtn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--fm-radius-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  min-width: 120px;
  padding: 10px 14px;
}

.fmBtnPrimary {
  background: var(--fm-primary);
  color: var(--fm-primary-foreground);
}

.fmBtnPrimary:hover {
  background: var(--fm-primary-hover);
}

.fmBtnSecondary {
  background: var(--fm-surface);
  border-color: var(--fm-border);
  color: var(--fm-text);
}

.fmBtnSecondary:hover {
  background: var(--fm-surface-muted);
}

.fmBtn:focus-visible {
  outline: none;
  box-shadow: var(--fm-focus-ring);
}

/* Theme segmented control */
.fmThemeToggle {
  display: grid;
  gap: 6px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--fm-border-subtle);
}

.fmThemeToggleLabel {
  color: var(--fm-text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fmThemeSeg {
  background: var(--fm-surface-muted);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-md);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
}

.fmThemeSeg button {
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--fm-text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 4px;
}

.fmThemeSeg button.isActive {
  background: var(--fm-surface);
  box-shadow: var(--fm-shadow-sm);
  color: var(--fm-text);
}

/* Command palette */
.fmCmdOverlay {
  align-items: flex-start;
  backdrop-filter: blur(6px);
  background: rgba(15, 23, 42, 0.42);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 12vh 16px 24px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 12000;
}

[data-theme="dark"] .fmCmdOverlay {
  background: rgba(0, 0, 0, 0.55);
}

.fmCmdDialog {
  background: var(--fm-surface-elevated);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-xl);
  box-shadow: var(--fm-shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: min(560px, 72vh);
  overflow: hidden;
  width: min(640px, 100%);
}

.fmCmdSearchRow {
  align-items: center;
  border-bottom: 1px solid var(--fm-border);
  display: flex;
  gap: 10px;
  padding: 14px 16px;
}

.fmCmdSearchRow svg {
  color: var(--fm-text-muted);
  flex-shrink: 0;
}

.fmCmdInput {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fm-text);
  flex: 1;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  outline: none;
}

.fmCmdInput::placeholder {
  color: var(--fm-text-muted);
}

.fmCmdKbd {
  background: var(--fm-surface-muted);
  border: 1px solid var(--fm-border);
  border-radius: 6px;
  color: var(--fm-text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 6px;
}

.fmCmdList {
  flex: 1;
  overflow: auto;
  padding: 8px;
}

.fmCmdGroupTitle {
  color: var(--fm-text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 10px 10px 6px;
  text-transform: uppercase;
}

.fmCmdItem {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--fm-radius-md);
  color: var(--fm-text);
  cursor: pointer;
  display: grid;
  gap: 10px;
  grid-template-columns: 28px 1fr auto;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.fmCmdItem:hover,
.fmCmdItem.isActive {
  background: var(--fm-primary-soft);
}

.fmCmdItemIcon {
  align-items: center;
  display: flex;
  font-size: 16px;
  justify-content: center;
}

.fmCmdItemLabel {
  font-size: 14px;
  font-weight: 600;
}

.fmCmdItemHint {
  color: var(--fm-text-muted);
  font-size: 12px;
  margin-top: 2px;
}

.fmCmdItemMeta {
  color: var(--fm-text-muted);
  font-size: 11px;
  font-weight: 600;
}

.fmCmdEmpty {
  color: var(--fm-text-muted);
  font-size: 14px;
  padding: 28px 16px;
  text-align: center;
}

.fmCmdFooter {
  border-top: 1px solid var(--fm-border);
  color: var(--fm-text-muted);
  display: flex;
  font-size: 12px;
  gap: 14px;
  justify-content: space-between;
  padding: 10px 14px;
}
