/* GENERATED — do not edit by hand.
 * Classic-script mirror of /components for the UI kits: the same sources with their
 * module syntax removed, each file kept in its own scope, exposed as window.FF.
 * Regenerate after changing any component. If a compiled design-system bundle is already
 * loaded on the page, its namespace wins and nothing here is used.
 */

var Icon = (function () {
/**
 * Fair Farms Icon — Lucide glyph, masked so it always paints in currentColor.
 * 1.5px stroke, never filled, never in a coloured circle.
 */
function Icon({ name, size = 20, style, title, ...rest }) {
  const url = `https://unpkg.com/lucide-static@0.544.0/icons/${name}.svg`;
  // The mask arrives asynchronously; until it does the box would paint as a solid
  // rectangle, so hold it transparent until the glyph is decoded.
  const [ready, setReady] = React.useState(false);
  React.useEffect(() => {
    let live = true;
    const img = new Image();
    img.onload = () => live && setReady(true);
    img.onerror = () => live && setReady(true);
    img.src = url;
    return () => { live = false; };
  }, [url]);
  return (
    <span
      role={title ? 'img' : 'presentation'}
      aria-label={title}
      aria-hidden={title ? undefined : true}
      {...rest}
      style={{
        display: 'inline-block',
        width: size,
        height: size,
        flex: '0 0 auto',
        backgroundColor: 'currentColor',
        opacity: ready ? 1 : 0,
        transition: 'opacity var(--dur-fast, 140ms) var(--ease-standard, ease)',
        WebkitMaskImage: `url("${url}")`,
        maskImage: `url("${url}")`,
        WebkitMaskSize: 'contain',
        maskSize: 'contain',
        WebkitMaskRepeat: 'no-repeat',
        maskRepeat: 'no-repeat',
        WebkitMaskPosition: 'center',
        maskPosition: 'center',
        ...style,
      }}
    />
  );
}
return Icon;
})();

var Button = (function () {
/**
 * Fair Farms Button — square-shouldered (4px), ink-and-pepper.
 *
 * Variants:
 *  - "primary"   : pepper fill, the page's single most important action
 *  - "secondary" : hairline ink outline, transparent
 *  - "ghost"     : text only
 *  - "inverse"   : paper fill on ink bands
 */
function Button({
  children,
  variant = 'primary',
  size = 'md',
  icon,
  iconAfter,
  href,
  disabled = false,
  full = false,
  onClick,
  type = 'button',
  style,
  ...rest
}) {
  const sizes = {
    sm: { minHeight: 'var(--control-h-sm, 32px)', padding: '0 12px', fontSize: 13, gap: 6 },
    md: { minHeight: 'var(--control-h, 40px)', padding: '0 18px', fontSize: 15, gap: 8 },
    lg: { minHeight: 'var(--control-h-lg, 48px)', padding: '0 24px', fontSize: 16, gap: 10 },
  };

  const variants = {
    primary: {
      background: 'var(--action-primary-bg, #A93425)',
      color: 'var(--action-primary-fg, #FFF9F2)',
      borderColor: 'transparent',
      '--hover': 'var(--action-primary-bg-hover, #8F2A1D)',
      '--press': 'var(--action-primary-bg-press, #781F15)',
    },
    secondary: {
      background: 'transparent',
      color: 'var(--action-secondary-fg, #17140F)',
      borderColor: 'var(--action-secondary-border, #17140F)',
      '--hover': 'var(--action-secondary-bg-hover, rgba(23,20,15,.06))',
      '--press': 'rgba(23,20,15,.12)',
    },
    ghost: {
      background: 'transparent',
      color: 'var(--action-ghost-fg, #332E24)',
      borderColor: 'transparent',
      '--hover': 'var(--action-ghost-bg-hover, rgba(23,20,15,.05))',
      '--press': 'rgba(23,20,15,.1)',
    },
    inverse: {
      background: 'var(--ff-paper, #F7F2E8)',
      color: 'var(--ff-ink, #17140F)',
      borderColor: 'transparent',
      '--hover': '#FFFDF8',
      '--press': '#EFE7D8',
    },
  };
  const v = variants[variant] || variants.primary;

  const base = {
    display: full ? 'flex' : 'inline-flex',
    width: full ? '100%' : undefined,
    alignItems: 'center',
    justifyContent: 'center',
    fontFamily: 'var(--ff-font-sans, Archivo, sans-serif)',
    fontWeight: 600,
    lineHeight: 1.1,
    letterSpacing: '0.005em',
    textAlign: 'center',
    textDecoration: 'none',
    borderRadius: 'var(--radius-sm, 4px)',
    borderWidth: 1,
    borderStyle: 'solid',
    cursor: disabled ? 'not-allowed' : 'pointer',
    transition: 'var(--transition-control, all 140ms ease)',
    ...sizes[size],
    ...(disabled
      ? {
          background: 'var(--action-disabled-bg, #EFE7D8)',
          color: 'var(--action-disabled-fg, #8A8271)',
          borderColor: 'transparent',
        }
      : { background: v.background, color: v.color, borderColor: v.borderColor }),
  };

  const Comp = href && !disabled ? 'a' : 'button';
  const tagProps = href && !disabled ? { href } : { type, disabled };
  const setBg = (el, val) => {
    if (variant === 'secondary' || variant === 'ghost') el.style.backgroundColor = val === 'rest' ? 'transparent' : val;
    else el.style.backgroundColor = val === 'rest' ? v.background : val;
  };

  return (
    <Comp
      {...tagProps}
      {...rest}
      onClick={disabled ? undefined : onClick}
      style={{ ...base, ...style }}
      onMouseEnter={(e) => !disabled && setBg(e.currentTarget, v['--hover'])}
      onMouseLeave={(e) => {
        if (disabled) return;
        setBg(e.currentTarget, 'rest');
        e.currentTarget.style.transform = 'translateY(0)';
      }}
      onMouseDown={(e) => {
        if (disabled) return;
        setBg(e.currentTarget, v['--press']);
        e.currentTarget.style.transform = 'translateY(1px)';
      }}
      onMouseUp={(e) => {
        if (disabled) return;
        setBg(e.currentTarget, v['--hover']);
        e.currentTarget.style.transform = 'translateY(0)';
      }}
    >
      {icon ? <Icon name={icon} size={size === 'sm' ? 14 : 16} /> : null}
      {children}
      {iconAfter ? <Icon name={iconAfter} size={size === 'sm' ? 14 : 16} /> : null}
    </Comp>
  );
}
return Button;
})();

var IconButton = (function () {
/** Square icon-only control — toolbars, table rows, dialog close, mobile nav. */
function IconButton({ icon, label, size = 'md', variant = 'ghost', onClick, disabled = false, style, ...rest }) {
  const box = { sm: 32, md: 40, lg: 44 }[size] || 40;
  const glyph = { sm: 16, md: 20, lg: 22 }[size] || 20;
  const skins = {
    ghost: { background: 'transparent', color: 'var(--action-ghost-fg, #332E24)', border: '1px solid transparent', hover: 'var(--action-ghost-bg-hover, rgba(23,20,15,.05))' },
    outline: { background: 'var(--surface-card, #FFFDF8)', color: 'var(--text-strong, #17140F)', border: '1px solid var(--border-hairline, #E4D9C5)', hover: 'var(--surface-sunken, #EFE7D8)' },
    solid: { background: 'var(--action-primary-bg, #A93425)', color: 'var(--action-primary-fg, #FFF9F2)', border: '1px solid transparent', hover: 'var(--action-primary-bg-hover, #8F2A1D)' },
  };
  const s = skins[variant] || skins.ghost;
  return (
    <button
      type="button"
      aria-label={label}
      title={label}
      disabled={disabled}
      onClick={disabled ? undefined : onClick}
      {...rest}
      style={{
        display: 'inline-flex',
        alignItems: 'center',
        justifyContent: 'center',
        width: box,
        height: box,
        borderRadius: 'var(--radius-sm, 4px)',
        cursor: disabled ? 'not-allowed' : 'pointer',
        transition: 'var(--transition-control, all 140ms ease)',
        background: s.background,
        color: disabled ? 'var(--action-disabled-fg, #8A8271)' : s.color,
        border: s.border,
        ...style,
      }}
      onMouseEnter={(e) => !disabled && (e.currentTarget.style.backgroundColor = s.hover)}
      onMouseLeave={(e) => !disabled && (e.currentTarget.style.backgroundColor = s.background)}
    >
      <Icon name={icon} size={glyph} />
    </button>
  );
}
return IconButton;
})();

var Card = (function () {
/**
 * Hairline card — 6px radius, 1px paper-3 border, no resting shadow.
 * Interactive cards lift with shadow-2 on hover; static cards never move.
 */
function Card({ children, as = 'div', href, padding = 'md', tone = 'card', interactive = false, style, ...rest }) {
  const pads = { none: 0, sm: 'var(--space-4, 16px)', md: 'var(--space-6, 24px)', lg: 'var(--space-7, 32px)' };
  const tones = {
    card: { background: 'var(--surface-card, #FFFDF8)' },
    sunken: { background: 'var(--surface-sunken, #EFE7D8)' },
    accent: { background: 'var(--surface-accent-soft, #F6E4DF)' },
    hatch: { background: 'var(--hatch, #EFE7D8)' },
  };
  const Comp = href ? 'a' : as;
  return (
    <Comp
      href={href}
      {...rest}
      style={{
        display: 'block',
        position: 'relative',
        borderRadius: 'var(--radius-md, 6px)',
        border: '1px solid var(--border-hairline, #E4D9C5)',
        padding: pads[padding],
        color: 'var(--text-body, #332E24)',
        textDecoration: 'none',
        transition: 'var(--transition-surface, all 220ms ease)',
        ...tones[tone],
        ...style,
      }}
      onMouseEnter={(e) => {
        if (!interactive && !href) return;
        e.currentTarget.style.boxShadow = 'var(--shadow-2, 0 2px 10px rgba(23,20,15,.08))';
        e.currentTarget.style.borderColor = 'var(--border-strong, #CBBBA0)';
      }}
      onMouseLeave={(e) => {
        if (!interactive && !href) return;
        e.currentTarget.style.boxShadow = 'none';
        e.currentTarget.style.borderColor = 'var(--border-hairline, #E4D9C5)';
      }}
    >
      {children}
    </Comp>
  );
}
return Card;
})();

var Badge = (function () {
/** Status pill: certification and lot state. Always carries a word, never colour alone. */
function Badge({ children, tone = 'neutral', icon, size = 'md', style, ...rest }) {
  const tones = {
    neutral: { color: 'var(--text-body, #332E24)', background: 'var(--surface-sunken, #EFE7D8)' },
    organic: { color: 'var(--status-organic, #46603A)', background: 'var(--status-organic-soft, #E4EADD)' },
    fair: { color: 'var(--status-fair, #C4703A)', background: 'var(--status-fair-soft, #F7E7DA)' },
    info: { color: 'var(--status-info, #245F58)', background: 'var(--status-info-soft, #DDE9E6)' },
    warning: { color: 'var(--status-warning, #B98829)', background: 'var(--status-warning-soft, #F7EBD2)' },
    danger: { color: 'var(--status-danger, #A93425)', background: 'var(--status-danger-soft, #F6E4DF)' },
    ink: { color: 'var(--ff-paper, #F7F2E8)', background: 'var(--ff-ink, #17140F)' },
  };
  const t = tones[tone] || tones.neutral;
  return (
    <span
      {...rest}
      style={{
        display: 'inline-flex',
        alignItems: 'center',
        gap: 6,
        padding: size === 'sm' ? '3px 8px' : '5px 10px',
        borderRadius: 'var(--radius-pill, 999px)',
        fontFamily: 'var(--ff-font-sans, Archivo, sans-serif)',
        fontSize: size === 'sm' ? 11 : 12,
        fontWeight: 600,
        letterSpacing: '0.02em',
        whiteSpace: 'nowrap',
        ...t,
        ...style,
      }}
    >
      {icon ? <Icon name={icon} size={size === 'sm' ? 12 : 14} /> : null}
      {children}
    </span>
  );
}
return Badge;
})();

var Tag = (function () {
/** Filter / attribute chip. Square-ish, hairline, optionally selectable or removable. */
function Tag({ children, selected = false, onClick, onRemove, style, ...rest }) {
  const clickable = Boolean(onClick);
  return (
    <span
      {...rest}
      onClick={onClick}
      role={clickable ? 'button' : undefined}
      tabIndex={clickable ? 0 : undefined}
      style={{
        display: 'inline-flex',
        alignItems: 'center',
        gap: 6,
        padding: '5px 10px',
        borderRadius: 'var(--radius-sm, 4px)',
        border: '1px solid ' + (selected ? 'var(--ff-ink, #17140F)' : 'var(--border-hairline, #E4D9C5)'),
        background: selected ? 'var(--ff-ink, #17140F)' : 'var(--surface-card, #FFFDF8)',
        color: selected ? 'var(--ff-paper, #F7F2E8)' : 'var(--text-body, #332E24)',
        font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)',
        cursor: clickable ? 'pointer' : 'default',
        transition: 'var(--transition-control, all 140ms ease)',
        ...style,
      }}
    >
      {children}
      {onRemove ? (
        <span
          onClick={(e) => { e.stopPropagation(); onRemove(e); }}
          style={{ display: 'inline-flex', cursor: 'pointer', opacity: 0.7 }}
        >
          <Icon name="x" size={13} />
        </span>
      ) : null}
    </span>
  );
}
return Tag;
})();

var Seal = (function () {
const ART = {
  ink: 'assets/logos/fair-farms-seal-ink.svg',
  paper: 'assets/logos/fair-farms-seal-paper.svg',
  pepper: 'assets/logos/fair-farms-seal-pepper.svg',
};

/**
 * The Fair Farms seal — the brand's authority stamp.
 * One colour, no shadow, never rotated or cropped. Clear space = 25% of diameter.
 * `lockup` adds the wordmark; `assetBase` prefixes the SVG path when the consuming
 * page sits in a subdirectory (e.g. assetBase="../../").
 */
function Seal({ size = 64, colour = 'ink', lockup = false, tagline, assetBase = '', href, style, ...rest }) {
  const src = assetBase + (ART[colour] || ART.ink);
  const mark = (
    <img
      src={src}
      alt="Fair Farms"
      width={size}
      height={size}
      style={{ display: 'block', width: size, height: size, flex: '0 0 auto' }}
    />
  );
  if (!lockup) {
    const Wrap = href ? 'a' : 'span';
    return (
      <Wrap href={href} {...rest} style={{ display: 'inline-block', padding: size * 0.25, ...style }}>
        {mark}
      </Wrap>
    );
  }
  const Wrap = href ? 'a' : 'span';
  return (
    <Wrap
      href={href}
      {...rest}
      style={{ display: 'inline-flex', alignItems: 'center', gap: 16, textDecoration: 'none', color: 'inherit', ...style }}
    >
      {mark}
      <span style={{ display: 'flex', flexDirection: 'column', gap: 3, borderLeft: '1px solid var(--border-strong, #CBBBA0)', paddingLeft: 16 }}>
        <span style={{ font: 'var(--type-title-1, 500 28px/1.24 Newsreader, serif)', fontSize: Math.max(17, size * 0.32), color: 'var(--text-strong, #17140F)', letterSpacing: '-0.01em' }}>
          Fair Farms
        </span>
        {tagline ? (
          <span style={{ font: 'var(--type-label, 600 12px/1.2 Archivo, sans-serif)', letterSpacing: '0.1em', textTransform: 'uppercase', color: 'var(--text-meta, #8A8271)' }}>
            {tagline}
          </span>
        ) : null}
      </span>
    </Wrap>
  );
}
return Seal;
})();

var CertBadge = (function () {
/**
 * Certification lockup — licensed mark plus its machine-readable evidence.
 * A mark on its own is decoration; this pairs it with number and date.
 */
function CertBadge({ name, art, number, date, note, height = 44, layout = 'row', assetBase = '', style, ...rest }) {
  const stack = layout === 'stack';
  return (
    <div
      {...rest}
      style={{
        display: 'flex',
        flexDirection: stack ? 'column' : 'row',
        alignItems: stack ? 'flex-start' : 'center',
        gap: stack ? 10 : 14,
        ...style,
      }}
    >
      {art ? (
        <img
          src={assetBase + art}
          alt={name}
          style={{ height, width: 'auto', display: 'block', flex: '0 0 auto' }}
        />
      ) : (
        <span
          aria-hidden="true"
          style={{
            display: 'flex', alignItems: 'center', justifyContent: 'center',
            height, minWidth: height * 1.9, padding: '0 10px',
            border: '1px dashed var(--border-strong, #CBBBA0)',
            borderRadius: 'var(--radius-xs, 2px)',
            background: 'var(--hatch, #EFE7D8)',
            font: 'var(--type-mono, 500 13px/1.5 monospace)', fontSize: 10,
            letterSpacing: '0.06em', textTransform: 'uppercase', color: 'var(--text-meta, #8A8271)',
            textAlign: 'center',
          }}
        >
          mark pending
        </span>
      )}
      <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
        <span style={{ font: 'var(--type-title-3, 600 18px/1.38 Archivo, sans-serif)', fontSize: 14, color: 'var(--text-strong, #17140F)' }}>{name}</span>
        {number ? (
          <span style={{ font: 'var(--type-mono, 500 13px/1.5 monospace)', fontSize: 12, color: 'var(--text-muted, #5C5545)' }}>{number}</span>
        ) : null}
        {date ? (
          <span style={{ font: 'var(--type-meta, 400 12px/1.45 Archivo, sans-serif)', color: 'var(--text-meta, #8A8271)' }}>{date}</span>
        ) : null}
        {note ? (
          <span style={{ font: 'var(--type-meta, 400 12px/1.45 Archivo, sans-serif)', color: 'var(--text-meta, #8A8271)' }}>{note}</span>
        ) : null}
      </div>
    </div>
  );
}
return CertBadge;
})();

var Eyebrow = (function () {
/** Small tracked label that opens a section. The only uppercase text in the system. */
function Eyebrow({ children, rule = true, tone = 'meta', style, ...rest }) {
  const colours = {
    meta: 'var(--text-meta, #8A8271)',
    accent: 'var(--text-accent, #A93425)',
    strong: 'var(--text-strong, #17140F)',
  };
  return (
    <span
      {...rest}
      style={{
        display: 'inline-flex',
        alignItems: 'center',
        gap: 10,
        font: 'var(--type-label, 600 12px/1.2 Archivo, sans-serif)',
        letterSpacing: '0.1em',
        textTransform: 'uppercase',
        color: colours[tone] || colours.meta,
        ...style,
      }}
    >
      {rule ? <span aria-hidden="true" style={{ width: 24, height: 2, background: 'var(--ff-pepper, #A93425)' }} /> : null}
      {children}
    </span>
  );
}
return Eyebrow;
})();

var Input = (function () {
const inputShell = (invalid, disabled) => ({
  width: '100%',
  minHeight: 'var(--control-h, 40px)',
  padding: '8px 12px',
  font: 'var(--type-body, 400 16px/1.65 Archivo, sans-serif)',
  fontSize: 15,
  color: disabled ? 'var(--action-disabled-fg, #8A8271)' : 'var(--text-strong, #17140F)',
  WebkitTextFillColor: disabled ? 'var(--action-disabled-fg, #8A8271)' : undefined,
  background: disabled ? 'var(--action-disabled-bg, #EFE7D8)' : 'var(--surface-card, #FFFDF8)',
  border: '1px solid ' + (disabled ? 'transparent' : invalid ? 'var(--status-danger, #A93425)' : 'var(--border-strong, #CBBBA0)'),
  borderRadius: 'var(--radius-sm, 4px)',
  outline: 'none',
  transition: 'var(--transition-control, all 140ms ease)',
});

/** Labelled text field with hint and error text. Labels are always visible — no placeholder-only fields. */
function Input({
  label, hint, error, id, type = 'text', mono = false, required = false, disabled = false,
  prefix, suffix, style, containerStyle, ...rest
}) {
  const uid = id || React.useId();
  const invalid = Boolean(error);
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 6, ...containerStyle }}>
      {label ? (
        <label htmlFor={uid} style={{ font: 'var(--type-label, 600 12px/1.2 Archivo, sans-serif)', letterSpacing: '0.06em', textTransform: 'uppercase', color: 'var(--text-muted, #5C5545)' }}>
          {label}
          {required ? <span style={{ color: 'var(--status-danger, #A93425)' }}> *</span> : null}
        </label>
      ) : null}
      <div style={{ display: 'flex', alignItems: 'stretch', gap: 0, position: 'relative' }}>
        {prefix ? (
          <span style={{ display: 'flex', alignItems: 'center', padding: '0 10px', background: 'var(--surface-sunken, #EFE7D8)', border: '1px solid var(--border-strong, #CBBBA0)', borderRight: 'none', borderRadius: '4px 0 0 4px', font: 'var(--type-mono, 500 13px/1.5 monospace)', color: 'var(--text-muted, #5C5545)' }}>{prefix}</span>
        ) : null}
        <input
          id={uid}
          type={type}
          required={required}
          disabled={disabled}
          aria-invalid={invalid || undefined}
          aria-describedby={hint || error ? uid + '-desc' : undefined}
          {...rest}
          style={{
            ...inputShell(invalid, disabled),
            ...(mono ? { fontFamily: 'var(--ff-font-mono, monospace)', letterSpacing: '0.02em', textTransform: 'uppercase' } : null),
            ...(prefix ? { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 } : null),
            ...(suffix ? { borderTopRightRadius: 0, borderBottomRightRadius: 0 } : null),
            ...style,
          }}
          onFocus={(e) => { e.currentTarget.style.borderColor = 'var(--border-focus, #245F58)'; e.currentTarget.style.boxShadow = '0 0 0 3px var(--ff-sea-tint, #DDE9E6)'; }}
          onBlur={(e) => { e.currentTarget.style.borderColor = invalid ? 'var(--status-danger, #A93425)' : 'var(--border-strong, #CBBBA0)'; e.currentTarget.style.boxShadow = 'none'; }}
        />
        {suffix ? (
          <span style={{ display: 'flex', alignItems: 'center', padding: '0 10px', background: 'var(--surface-sunken, #EFE7D8)', border: '1px solid var(--border-strong, #CBBBA0)', borderLeft: 'none', borderRadius: '0 4px 4px 0', font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)', color: 'var(--text-muted, #5C5545)' }}>{suffix}</span>
        ) : null}
      </div>
      {hint || error ? (
        <span id={uid + '-desc'} style={{ font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)', fontSize: 13, color: invalid ? 'var(--status-danger, #A93425)' : 'var(--text-meta, #8A8271)' }}>
          {error || hint}
        </span>
      ) : null}
    </div>
  );
}
return Input;
})();

var Select = (function () {
const selectShell = (invalid, disabled) => ({
  width: '100%',
  minHeight: 'var(--control-h, 40px)',
  padding: '8px 12px',
  font: 'var(--type-body, 400 16px/1.65 Archivo, sans-serif)',
  fontSize: 15,
  color: disabled ? 'var(--action-disabled-fg, #8A8271)' : 'var(--text-strong, #17140F)',
  background: disabled ? 'var(--action-disabled-bg, #EFE7D8)' : 'var(--surface-card, #FFFDF8)',
  border: '1px solid ' + (disabled ? 'transparent' : invalid ? 'var(--status-danger, #A93425)' : 'var(--border-strong, #CBBBA0)'),
  borderRadius: 'var(--radius-sm, 4px)',
  outline: 'none',
  transition: 'var(--transition-control, all 140ms ease)',
});

/** Native select in Fair Farms clothing — keeps mobile and Khmer input sane. */
function Select({ label, hint, error, id, options = [], disabled = false, children, style, containerStyle, ...rest }) {
  const uid = id || React.useId();
  const invalid = Boolean(error);
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 6, ...containerStyle }}>
      {label ? (
        <label htmlFor={uid} style={{ font: 'var(--type-label, 600 12px/1.2 Archivo, sans-serif)', letterSpacing: '0.06em', textTransform: 'uppercase', color: 'var(--text-muted, #5C5545)' }}>{label}</label>
      ) : null}
      <select
        id={uid}
        disabled={disabled}
        aria-invalid={invalid || undefined}
        {...rest}
        style={{
          ...selectShell(invalid, disabled),
          appearance: 'none',
          paddingRight: 34,
          cursor: disabled ? 'not-allowed' : 'pointer',
          backgroundImage: 'linear-gradient(45deg, transparent 50%, var(--text-muted, #5C5545) 50%), linear-gradient(135deg, var(--text-muted, #5C5545) 50%, transparent 50%)',
          backgroundPosition: 'calc(100% - 18px) 50%, calc(100% - 13px) 50%',
          backgroundSize: '5px 5px, 5px 5px',
          backgroundRepeat: 'no-repeat',
          ...style,
        }}
        onFocus={(e) => { e.currentTarget.style.borderColor = 'var(--border-focus, #245F58)'; e.currentTarget.style.boxShadow = '0 0 0 3px var(--ff-sea-tint, #DDE9E6)'; }}
        onBlur={(e) => { e.currentTarget.style.borderColor = invalid ? 'var(--status-danger, #A93425)' : 'var(--border-strong, #CBBBA0)'; e.currentTarget.style.boxShadow = 'none'; }}
      >
        {options.map((o) => (
          <option key={typeof o === 'string' ? o : o.value} value={typeof o === 'string' ? o : o.value}>
            {typeof o === 'string' ? o : o.label}
          </option>
        ))}
        {children}
      </select>
      {hint || error ? (
        <span style={{ font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)', fontSize: 13, color: invalid ? 'var(--status-danger, #A93425)' : 'var(--text-meta, #8A8271)' }}>{error || hint}</span>
      ) : null}
    </div>
  );
}
return Select;
})();

var Checkbox = (function () {
/** Square 18px checkbox with ink fill when checked. */
function Checkbox({ label, hint, checked, defaultChecked, onChange, disabled = false, id, style, ...rest }) {
  const uid = id || React.useId();
  const [inner, setInner] = React.useState(Boolean(defaultChecked));
  const isOn = checked === undefined ? inner : checked;
  return (
    <label
      htmlFor={uid}
      style={{ display: 'flex', gap: 10, alignItems: 'flex-start', cursor: disabled ? 'not-allowed' : 'pointer', minHeight: 24, ...style }}
    >
      <input
        id={uid}
        type="checkbox"
        checked={isOn}
        disabled={disabled}
        onChange={(e) => { if (checked === undefined) setInner(e.target.checked); onChange && onChange(e); }}
        {...rest}
        style={{ position: 'absolute', opacity: 0, width: 1, height: 1 }}
      />
      <span
        aria-hidden="true"
        style={{
          display: 'flex', alignItems: 'center', justifyContent: 'center',
          width: 18, height: 18, marginTop: 2, flex: '0 0 auto',
          borderRadius: 'var(--radius-xs, 2px)',
          border: '1px solid ' + (isOn ? 'var(--ff-ink, #17140F)' : 'var(--border-strong, #CBBBA0)'),
          background: isOn ? 'var(--ff-ink, #17140F)' : 'var(--surface-card, #FFFDF8)',
          color: 'var(--ff-paper, #F7F2E8)',
          transition: 'var(--transition-control, all 140ms ease)',
          opacity: disabled ? 0.55 : 1,
        }}
      >
        {isOn ? <Icon name="check" size={13} /> : null}
      </span>
      <span style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
        <span style={{ font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)', fontSize: 15, color: 'var(--text-body, #332E24)' }}>{label}</span>
        {hint ? <span style={{ font: 'var(--type-meta, 400 12px/1.45 Archivo, sans-serif)', color: 'var(--text-meta, #8A8271)' }}>{hint}</span> : null}
      </span>
    </label>
  );
}
return Checkbox;
})();

var Radio = (function () {
/** Radio row. Group them with a shared `name`; one visible label each. */
function Radio({ label, hint, name, value, checked, onChange, disabled = false, id, style, ...rest }) {
  const uid = id || React.useId();
  return (
    <label htmlFor={uid} style={{ display: 'flex', gap: 10, alignItems: 'flex-start', cursor: disabled ? 'not-allowed' : 'pointer', minHeight: 24, ...style }}>
      <input
        id={uid} type="radio" name={name} value={value} checked={checked} disabled={disabled} onChange={onChange}
        {...rest}
        style={{ position: 'absolute', opacity: 0, width: 1, height: 1 }}
      />
      <span
        aria-hidden="true"
        style={{
          display: 'flex', alignItems: 'center', justifyContent: 'center',
          width: 18, height: 18, marginTop: 2, flex: '0 0 auto',
          borderRadius: '50%',
          border: '1px solid ' + (checked ? 'var(--ff-pepper, #A93425)' : 'var(--border-strong, #CBBBA0)'),
          background: 'var(--surface-card, #FFFDF8)',
          transition: 'var(--transition-control, all 140ms ease)',
          opacity: disabled ? 0.55 : 1,
        }}
      >
        {checked ? <span style={{ width: 9, height: 9, borderRadius: '50%', background: 'var(--ff-pepper, #A93425)' }} /> : null}
      </span>
      <span style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
        <span style={{ font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)', fontSize: 15, color: 'var(--text-body, #332E24)' }}>{label}</span>
        {hint ? <span style={{ font: 'var(--type-meta, 400 12px/1.45 Archivo, sans-serif)', color: 'var(--text-meta, #8A8271)' }}>{hint}</span> : null}
      </span>
    </label>
  );
}
return Radio;
})();

var Switch = (function () {
/** Switch — for settings that apply immediately (notifications, language sync). */
function Switch({ label, hint, checked, defaultChecked, onChange, disabled = false, id, style, ...rest }) {
  const uid = id || React.useId();
  const [inner, setInner] = React.useState(Boolean(defaultChecked));
  const isOn = checked === undefined ? inner : checked;
  return (
    <label htmlFor={uid} style={{ display: 'flex', gap: 12, alignItems: 'center', justifyContent: 'space-between', cursor: disabled ? 'not-allowed' : 'pointer', minHeight: 'var(--tap-min, 44px)', ...style }}>
      <span style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
        <span style={{ font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)', fontSize: 15, color: 'var(--text-body, #332E24)' }}>{label}</span>
        {hint ? <span style={{ font: 'var(--type-meta, 400 12px/1.45 Archivo, sans-serif)', color: 'var(--text-meta, #8A8271)' }}>{hint}</span> : null}
      </span>
      <input
        id={uid} type="checkbox" role="switch" checked={isOn} disabled={disabled}
        onChange={(e) => { if (checked === undefined) setInner(e.target.checked); onChange && onChange(e); }}
        {...rest}
        style={{ position: 'absolute', opacity: 0, width: 1, height: 1 }}
      />
      <span
        aria-hidden="true"
        style={{
          position: 'relative', width: 40, height: 22, flex: '0 0 auto',
          borderRadius: 'var(--radius-pill, 999px)',
          background: isOn ? 'var(--ff-ink, #17140F)' : 'var(--ff-paper-3, #E4D9C5)',
          border: '1px solid ' + (isOn ? 'var(--ff-ink, #17140F)' : 'var(--border-strong, #CBBBA0)'),
          transition: 'var(--transition-control, all 140ms ease)',
          opacity: disabled ? 0.55 : 1,
        }}
      >
        <span
          style={{
            position: 'absolute', top: 2, left: isOn ? 20 : 2,
            width: 16, height: 16, borderRadius: '50%',
            background: 'var(--ff-card, #FFFDF8)',
            transition: 'left var(--dur-fast, 140ms) var(--ease-standard, ease)',
          }}
        />
      </span>
    </label>
  );
}
return Switch;
})();

var Tabs = (function () {
/** Underlined tabs — 2px pepper rule marks the selected tab. */
function Tabs({ items = [], value, onChange, style, ...rest }) {
  const [inner, setInner] = React.useState(items[0] && (items[0].value || items[0]));
  const active = value === undefined ? inner : value;
  const pick = (v) => { if (value === undefined) setInner(v); onChange && onChange(v); };
  return (
    <div
      role="tablist"
      {...rest}
      style={{ display: 'flex', gap: 'var(--space-6, 24px)', borderBottom: '1px solid var(--border-hairline, #E4D9C5)', overflowX: 'auto', ...style }}
    >
      {items.map((raw) => {
        const it = typeof raw === 'string' ? { value: raw, label: raw } : raw;
        const on = it.value === active;
        return (
          <button
            key={it.value}
            role="tab"
            aria-selected={on}
            onClick={() => pick(it.value)}
            style={{
              display: 'inline-flex', alignItems: 'center', gap: 8,
              padding: '10px 0 12px',
              background: 'none', border: 'none', cursor: 'pointer',
              font: 'var(--type-title-3, 600 18px/1.38 Archivo, sans-serif)', fontSize: 15,
              color: on ? 'var(--text-strong, #17140F)' : 'var(--text-muted, #5C5545)',
              boxShadow: on ? 'inset 0 -2px 0 0 var(--ff-pepper, #A93425)' : 'none',
              whiteSpace: 'nowrap',
              transition: 'var(--transition-control, all 140ms ease)',
            }}
          >
            {it.label}
            {it.count !== undefined ? (
              <span style={{ font: 'var(--type-mono, 500 13px/1.5 monospace)', fontSize: 12, color: 'var(--text-meta, #8A8271)' }}>{it.count}</span>
            ) : null}
          </button>
        );
      })}
    </div>
  );
}
return Tabs;
})();

var Dialog = (function () {
/** Modal panel: ink scrim, 10px radius, 12px rise. Escape and scrim both close. */
function Dialog({ open = false, title, description, onClose, footer, children, width = 520, style, ...rest }) {
  React.useEffect(() => {
    if (!open) return;
    const onKey = (e) => e.key === 'Escape' && onClose && onClose();
    document.addEventListener('keydown', onKey);
    return () => document.removeEventListener('keydown', onKey);
  }, [open, onClose]);
  if (!open) return null;
  return (
    <div
      onClick={onClose}
      style={{
        position: 'fixed', inset: 0, zIndex: 60,
        display: 'flex', alignItems: 'center', justifyContent: 'center',
        padding: 'var(--space-6, 24px)',
        background: 'var(--surface-overlay, rgba(23,20,15,.62))',
        animation: 'ff-fade var(--dur-base, 220ms) var(--ease-standard, ease)',
      }}
    >
      <div
        role="dialog"
        aria-modal="true"
        aria-label={title}
        onClick={(e) => e.stopPropagation()}
        {...rest}
        style={{
          width: '100%', maxWidth: width, maxHeight: '86vh', overflowY: 'auto',
          background: 'var(--surface-card, #FFFDF8)',
          border: '1px solid var(--border-hairline, #E4D9C5)',
          borderRadius: 'var(--radius-lg, 10px)',
          boxShadow: 'var(--shadow-3, 0 18px 44px -14px rgba(23,20,15,.28))',
          animation: 'ff-rise var(--dur-base, 220ms) var(--ease-standard, ease)',
          ...style,
        }}
      >
        <style>{'@keyframes ff-fade{from{opacity:0}to{opacity:1}}@keyframes ff-rise{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}'}</style>
        <header style={{ display: 'flex', alignItems: 'flex-start', gap: 16, padding: 'var(--space-6, 24px)', borderBottom: '1px solid var(--border-hairline, #E4D9C5)' }}>
          <div style={{ flex: 1, display: 'flex', flexDirection: 'column', gap: 4 }}>
            <h2 style={{ margin: 0, font: 'var(--type-title-1, 500 28px/1.24 Newsreader, serif)', fontSize: 22, color: 'var(--text-strong, #17140F)' }}>{title}</h2>
            {description ? <p style={{ margin: 0, font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)', color: 'var(--text-muted, #5C5545)' }}>{description}</p> : null}
          </div>
          {onClose ? <IconButton icon="x" label="Close" onClick={onClose} /> : null}
        </header>
        <div style={{ padding: 'var(--space-6, 24px)', font: 'var(--type-body, 400 16px/1.65 Archivo, sans-serif)', color: 'var(--text-body, #332E24)' }}>{children}</div>
        {footer ? (
          <footer style={{ display: 'flex', justifyContent: 'flex-end', gap: 'var(--space-3, 12px)', padding: 'var(--space-6, 24px)', borderTop: '1px solid var(--border-hairline, #E4D9C5)', background: 'var(--surface-sunken, #EFE7D8)', borderRadius: '0 0 10px 10px' }}>{footer}</footer>
        ) : null}
      </div>
    </div>
  );
}
return Dialog;
})();

var Toast = (function () {
/** Ink toast, bottom-left, 4s auto-dismiss. Confirmation only — errors stay inline. */
function Toast({ open = true, message, detail, tone = 'default', onClose, duration = 4000, style, ...rest }) {
  React.useEffect(() => {
    if (!open || !onClose || !duration) return;
    const t = setTimeout(onClose, duration);
    return () => clearTimeout(t);
  }, [open, onClose, duration]);
  if (!open) return null;
  const icons = { default: 'check', saved: 'check', warning: 'alert-triangle', danger: 'alert-circle' };
  const accents = { default: 'var(--ff-leaf, #46603A)', saved: 'var(--ff-leaf, #46603A)', warning: 'var(--ff-gold, #B98829)', danger: 'var(--ff-pepper, #A93425)' };
  return (
    <div
      role="status"
      {...rest}
      style={{
        display: 'inline-flex', alignItems: 'flex-start', gap: 12,
        maxWidth: 420, padding: '14px 14px 14px 16px',
        background: 'var(--ff-ink, #17140F)',
        color: 'var(--ff-paper, #F7F2E8)',
        borderRadius: 'var(--radius-md, 6px)',
        borderLeft: '3px solid ' + accents[tone],
        boxShadow: 'var(--shadow-3, 0 18px 44px -14px rgba(23,20,15,.28))',
        ...style,
      }}
    >
      <Icon name={icons[tone]} size={18} style={{ marginTop: 2, color: accents[tone] }} />
      <span style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
        <span style={{ font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)', fontSize: 15, fontWeight: 500 }}>{message}</span>
        {detail ? <span style={{ font: 'var(--type-meta, 400 12px/1.45 Archivo, sans-serif)', color: 'rgba(247,242,232,.66)' }}>{detail}</span> : null}
      </span>
      {onClose ? <IconButton icon="x" label="Dismiss" size="sm" onClick={onClose} style={{ color: 'rgba(247,242,232,.7)' }} /> : null}
    </div>
  );
}
return Toast;
})();

var Tooltip = (function () {
/** Hover/focus tooltip on ink. Short factual labels only — never essential content. */
function Tooltip({ label, placement = 'top', children, style, ...rest }) {
  const [on, setOn] = React.useState(false);
  const pos = {
    top: { bottom: '100%', left: '50%', transform: 'translate(-50%, -8px)' },
    bottom: { top: '100%', left: '50%', transform: 'translate(-50%, 8px)' },
    left: { right: '100%', top: '50%', transform: 'translate(-8px, -50%)' },
    right: { left: '100%', top: '50%', transform: 'translate(8px, -50%)' },
  };
  return (
    <span
      {...rest}
      style={{ position: 'relative', display: 'inline-flex', ...style }}
      onMouseEnter={() => setOn(true)}
      onMouseLeave={() => setOn(false)}
      onFocus={() => setOn(true)}
      onBlur={() => setOn(false)}
    >
      {children}
      {on ? (
        <span
          role="tooltip"
          style={{
            position: 'absolute', zIndex: 70, ...pos[placement],
            padding: '6px 9px', whiteSpace: 'nowrap',
            background: 'var(--ff-ink, #17140F)', color: 'var(--ff-paper, #F7F2E8)',
            borderRadius: 'var(--radius-sm, 4px)',
            font: 'var(--type-meta, 400 12px/1.45 Archivo, sans-serif)',
            boxShadow: 'var(--shadow-2, 0 2px 10px rgba(23,20,15,.08))',
            pointerEvents: 'none',
          }}
        >
          {label}
        </span>
      ) : null}
    </span>
  );
}
return Tooltip;
})();

var Table = (function () {
/**
 * Data table: horizontal rules only, no zebra, no vertical grid.
 * 40px rows, uppercase 12px heads, mono for codes and numbers.
 */
function Table({ columns = [], rows = [], caption, dense = false, style, ...rest }) {
  const rowH = dense ? 36 : 44;
  return (
    <div style={{ width: '100%', overflowX: 'auto', ...style }}>
      <table {...rest} style={{ width: '100%', borderCollapse: 'collapse', font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)' }}>
        {caption ? (
          <caption style={{ captionSide: 'top', textAlign: 'left', paddingBottom: 10, font: 'var(--type-meta, 400 12px/1.45 Archivo, sans-serif)', color: 'var(--text-meta, #8A8271)' }}>{caption}</caption>
        ) : null}
        <thead>
          <tr>
            {columns.map((c) => (
              <th
                key={c.key}
                scope="col"
                style={{
                  textAlign: c.align || 'left',
                  padding: '0 12px 8px',
                  borderBottom: '1px solid var(--border-strong, #CBBBA0)',
                  font: 'var(--type-label, 600 12px/1.2 Archivo, sans-serif)',
                  letterSpacing: '0.08em', textTransform: 'uppercase',
                  color: 'var(--text-muted, #5C5545)', whiteSpace: 'nowrap',
                }}
              >
                {c.header}
              </th>
            ))}
          </tr>
        </thead>
        <tbody>
          {rows.map((r, i) => (
            <tr
              key={r.id || i}
              style={{ height: rowH, transition: 'background var(--dur-fast, 140ms) var(--ease-standard, ease)' }}
              onMouseEnter={(e) => (e.currentTarget.style.background = 'var(--surface-sunken, #EFE7D8)')}
              onMouseLeave={(e) => (e.currentTarget.style.background = 'transparent')}
            >
              {columns.map((c) => (
                <td
                  key={c.key}
                  style={{
                    padding: '0 12px',
                    textAlign: c.align || 'left',
                    borderBottom: '1px solid var(--border-hairline, #E4D9C5)',
                    color: 'var(--text-body, #332E24)',
                    fontFamily: c.mono ? 'var(--ff-font-mono, monospace)' : undefined,
                    fontSize: c.mono ? 13 : undefined,
                    fontVariantNumeric: 'tabular-nums',
                    whiteSpace: c.wrap ? 'normal' : 'nowrap',
                  }}
                >
                  {c.render ? c.render(r) : r[c.key]}
                </td>
              ))}
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  );
}
return Table;
})();

var LotCode = (function () {
/** Traceability code chip — mono, uppercase, copyable. The system's fingerprint. */
function LotCode({ code, label, size = 'md', copyable = false, style, ...rest }) {
  const [copied, setCopied] = React.useState(false);
  const copy = () => {
    if (!copyable || !navigator.clipboard) return;
    navigator.clipboard.writeText(code).then(() => {
      setCopied(true);
      setTimeout(() => setCopied(false), 1600);
    });
  };
  return (
    <span
      onClick={copy}
      title={copyable ? 'Copy code' : undefined}
      {...rest}
      style={{
        display: 'inline-flex', alignItems: 'center', gap: 8,
        padding: size === 'sm' ? '3px 7px' : '5px 9px',
        border: '1px solid var(--border-hairline, #E4D9C5)',
        borderRadius: 'var(--radius-xs, 2px)',
        background: 'var(--surface-sunken, #EFE7D8)',
        font: 'var(--type-mono, 500 13px/1.5 monospace)',
        fontSize: size === 'sm' ? 11 : 13,
        letterSpacing: '0.04em', textTransform: 'uppercase',
        color: 'var(--text-strong, #17140F)',
        cursor: copyable ? 'copy' : 'default',
        ...style,
      }}
    >
      {label ? <span style={{ color: 'var(--text-meta, #8A8271)', letterSpacing: '0.08em' }}>{label}</span> : null}
      {code}
      {copied ? <span style={{ color: 'var(--ff-leaf, #46603A)', letterSpacing: 0 }}>copied</span> : null}
    </span>
  );
}
return LotCode;
})();

var DataList = (function () {
/** Label/value spec list — product specs, shipment details, audit facts. */
function DataList({ items = [], columns = 1, dense = false, style, ...rest }) {
  return (
    <dl
      {...rest}
      style={{
        margin: 0, display: 'grid',
        gridTemplateColumns: 'repeat(' + columns + ', minmax(0, 1fr))',
        columnGap: 'var(--space-7, 32px)', rowGap: 0,
        ...style,
      }}
    >
      {items.map((it, i) => (
        <div
          key={it.label + i}
          style={{
            display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 16,
            padding: dense ? '8px 0' : '11px 0',
            borderBottom: '1px solid var(--border-hairline, #E4D9C5)',
          }}
        >
          <dt style={{ font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)', color: 'var(--text-muted, #5C5545)' }}>{it.label}</dt>
          <dd
            style={{
              margin: 0, textAlign: 'right',
              font: it.mono ? 'var(--type-mono, 500 13px/1.5 monospace)' : 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)',
              fontWeight: it.mono ? 500 : 600,
              color: 'var(--text-strong, #17140F)',
              fontVariantNumeric: 'tabular-nums',
            }}
          >
            {it.value}
          </dd>
        </div>
      ))}
    </dl>
  );
}
return DataList;
})();

var Textarea = (function () {
/** Multi-line field — enquiry notes, delivery remarks. Same shell as Input; the counter is optional and never blocks typing. */
function Textarea({
  label, hint, error, id, rows = 4, required = false, disabled = false, maxLength, value,
  style, containerStyle, ...rest
}) {
  const uid = id || React.useId();
  const invalid = Boolean(error);
  const used = typeof value === 'string' ? value.length : null;
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 6, ...containerStyle }}>
      {label ? (
        <label htmlFor={uid} style={{ font: 'var(--type-label, 600 12px/1.2 Archivo, sans-serif)', letterSpacing: '0.06em', textTransform: 'uppercase', color: 'var(--text-muted, #5C5545)' }}>
          {label}
          {required ? <span style={{ color: 'var(--status-danger, #A93425)' }}> *</span> : null}
        </label>
      ) : null}
      <textarea
        id={uid}
        rows={rows}
        required={required}
        maxLength={maxLength}
        value={value}
        disabled={disabled}
        aria-invalid={invalid || undefined}
        aria-describedby={hint || error ? uid + '-desc' : undefined}
        {...rest}
        style={{
          width: '100%',
          padding: '10px 12px',
          font: 'var(--type-body, 400 16px/1.65 Archivo, sans-serif)',
          fontSize: 15,
          color: disabled ? 'var(--action-disabled-fg, #8A8271)' : 'var(--text-strong, #17140F)',
          WebkitTextFillColor: disabled ? 'var(--action-disabled-fg, #8A8271)' : undefined,
          background: disabled ? 'var(--action-disabled-bg, #EFE7D8)' : 'var(--surface-card, #FFFDF8)',
          border: '1px solid ' + (disabled ? 'transparent' : invalid ? 'var(--status-danger, #A93425)' : 'var(--border-strong, #CBBBA0)'),
          borderRadius: 'var(--radius-sm, 4px)',
          outline: 'none',
          resize: 'vertical',
          transition: 'var(--transition-control, all 140ms ease)',
          ...style,
        }}
        onFocus={(e) => { e.currentTarget.style.borderColor = 'var(--border-focus, #245F58)'; e.currentTarget.style.boxShadow = '0 0 0 3px var(--ff-sea-tint, #DDE9E6)'; }}
        onBlur={(e) => { e.currentTarget.style.borderColor = invalid ? 'var(--status-danger, #A93425)' : 'var(--border-strong, #CBBBA0)'; e.currentTarget.style.boxShadow = 'none'; }}
      />
      {hint || error || maxLength ? (
        <div style={{ display: 'flex', gap: 12, alignItems: 'baseline' }}>
          <span id={uid + '-desc'} style={{ flex: 1, font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)', fontSize: 13, color: invalid ? 'var(--status-danger, #A93425)' : 'var(--text-meta, #8A8271)' }}>
            {error || hint}
          </span>
          {maxLength && used !== null ? (
            <span style={{ font: 'var(--type-mono, 500 13px/1.5 monospace)', fontSize: 11, color: 'var(--text-meta, #8A8271)', fontVariantNumeric: 'tabular-nums' }}>
              {used}/{maxLength}
            </span>
          ) : null}
        </div>
      ) : null}
    </div>
  );
}
return Textarea;
})();

var Fieldset = (function () {
/**
 * Group of related choices — checkboxes, radios, segmented rows.
 * Renders a real <fieldset>/<legend> so the group name is announced once,
 * and carries the group-level error (a radio group's error belongs to the group).
 */
function Fieldset({ legend, hint, error, required = false, layout = 'stack', columns = 2, children, style, ...rest }) {
  const invalid = Boolean(error);
  const layouts = {
    stack: { display: 'flex', flexDirection: 'column', gap: 10 },
    row: { display: 'flex', flexWrap: 'wrap', gap: '10px var(--space-6, 24px)' },
    grid: { display: 'grid', gridTemplateColumns: 'repeat(' + columns + ', minmax(0, 1fr))', gap: '10px var(--space-5, 20px)' },
  };
  return (
    <fieldset
      aria-invalid={invalid || undefined}
      {...rest}
      style={{ display: 'flex', flexDirection: 'column', gap: 6, margin: 0, padding: 0, border: 'none', minWidth: 0, ...style }}
    >
      {legend ? (
        <legend style={{ padding: 0, font: 'var(--type-label, 600 12px/1.2 Archivo, sans-serif)', letterSpacing: '0.06em', textTransform: 'uppercase', color: 'var(--text-muted, #5C5545)' }}>
          {legend}
          {required ? <span style={{ color: 'var(--status-danger, #A93425)' }}> *</span> : null}
        </legend>
      ) : null}
      <div
        style={{
          ...layouts[layout],
          paddingTop: 4,
          paddingLeft: invalid ? 12 : 0,
          borderLeft: invalid ? '2px solid var(--status-danger, #A93425)' : 'none',
          transition: 'var(--transition-control, all 140ms ease)',
        }}
      >
        {children}
      </div>
      {hint || error ? (
        <span style={{ font: 'var(--type-body-sm, 400 14px/1.58 Archivo, sans-serif)', fontSize: 13, color: invalid ? 'var(--status-danger, #A93425)' : 'var(--text-meta, #8A8271)' }}>
          {error || hint}
        </span>
      ) : null}
    </fieldset>
  );
}
return Fieldset;
})();

var ToastRegion = (function () {
/**
 * Fixed host for toasts — bottom-left by default, newest on top of the stack.
 * `contained` switches to absolute so the region can live inside a phone frame
 * or a portal panel instead of the viewport.
 */
function ToastRegion({ position = 'bottom-left', contained = false, children, style, ...rest }) {
  const inset = {
    'bottom-left': { left: 'var(--space-7, 32px)', bottom: 'var(--space-7, 32px)', alignItems: 'flex-start' },
    'bottom-right': { right: 'var(--space-7, 32px)', bottom: 'var(--space-7, 32px)', alignItems: 'flex-end' },
    'bottom-center': { left: '50%', bottom: 'var(--space-6, 24px)', transform: 'translateX(-50%)', alignItems: 'center' },
    'top-right': { right: 'var(--space-7, 32px)', top: 'var(--space-7, 32px)', alignItems: 'flex-end' },
  };
  return (
    <div
      {...rest}
      style={{
        position: contained ? 'absolute' : 'fixed',
        zIndex: 50,
        display: 'flex',
        flexDirection: 'column-reverse',
        gap: 'var(--space-3, 12px)',
        pointerEvents: 'none',
        ...(contained ? { left: 16, right: 16, bottom: 16, alignItems: 'stretch' } : inset[position] || inset['bottom-left']),
        ...style,
      }}
    >
      <style>{'@keyframes ff-toast-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}'}</style>
      {React.Children.map(children, (child) =>
        child ? (
          <div style={{ pointerEvents: 'auto', animation: 'ff-toast-in var(--dur-base, 220ms) var(--ease-standard, ease)' }}>{child}</div>
        ) : null
      )}
    </div>
  );
}
return ToastRegion;
})();

(function () {
  var compiled = Object.keys(window).filter(function (k) {
    return /DesignSystem_/.test(k) && window[k] && window[k].Button;
  })[0];
  var local = { Icon, Button, IconButton, Card, Badge, Tag, Seal, CertBadge, Eyebrow, Input, Select, Textarea, Fieldset, Checkbox, Radio, Switch, Tabs, Dialog, Toast, ToastRegion, Tooltip, Table, LotCode, DataList };
  // A compiled bundle may predate these; fill any gap from the local mirror.
  window.FF = compiled ? Object.assign({}, local, window[compiled]) : local;
  ['Textarea', 'Fieldset', 'ToastRegion'].forEach(function (k) { if (!window.FF[k]) window.FF[k] = local[k]; });
})();
