/**
 * mad-ui.css — Mini design system (shadcn + Tailwind inspired)
 * Versão : 1.0
 * Prefixo: mad-  →  zero conflito com Bootstrap / Adianti
 *
 * USO
 *   Envolva qualquer tela livre com <div class="mad-ui"> para ativar os tokens.
 *   Todas as classes funcionam globalmente graças ao prefixo mad-.
 *
 * TOKENS
 *   Sobrescreva variáveis em .mad-ui para tematizar por instância.
 *
 * COMPONENTES
 *   mad-btn      mad-card      mad-input / mad-select / mad-textarea
 *   mad-badge    mad-alert     mad-toggle    mad-avatar
 *   mad-tabs     mad-table     mad-spinner   mad-skeleton
 *   mad-drawer   mad-field     mad-section   mad-select-card
 *   mad-navbar   mad-rail      mad-megamenu  mad-submenu
 *
 * LAYOUT
 *   mad-flex  mad-grid  mad-stack-{n}  mad-cluster
 *
 * UTILITÁRIOS
 *   mad-p-{0-8}  mad-m-{0-8}  mad-gap-{0-8}
 *   mad-text-{xs|sm|base|lg|xl|2xl|3xl}
 *   mad-font-{normal|medium|semibold|bold}
 *   mad-rounded-{sm|md|lg|xl|full}
 *   mad-shadow-{sm|md|lg}
 *   mad-bg-*  mad-text-*  mad-border-*
 */

/* ═══════════════════════════════════════════════════════════════════
   1. DESIGN TOKENS
   ═══════════════════════════════════════════════════════════════════ */

:root,
.mad-ui {
  /* ── Backgrounds (zinc palette — Notch) ── */
  --mad-bg:           #ffffff;
  --mad-bg-subtle:    #fafafa;
  --mad-bg-muted:     #f4f4f5;   /* zinc-100 */

  /* ── Borders ── */
  --mad-border:       #e5e7eb;
  --mad-border-strong:#d4d4d8;   /* zinc-300 */

  /* ── Text ── */
  --mad-text:         #18181b;   /* zinc-900 */
  --mad-text-muted:   #52525b;   /* zinc-600 */
  --mad-text-subtle:  #a1a1aa;   /* zinc-400 */

  /* ── Primary (dark — padrão Notch) ── */
  --mad-primary:        #18181b;
  --mad-primary-hover:  #27272a;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #f4f4f5;

  /* ── Accent (herda --main-color do Adianti Builder)
     Usado em estados ativos de menu/nav.
     Fallback = primary (zinc-900).                    ── */
  --mad-accent:        var(--main-color, #18181b);
  --mad-accent-subtle: color-mix(in srgb, var(--main-color, #18181b) 6%, white);
  --mad-accent-border: color-mix(in srgb, var(--main-color, #18181b) 25%, transparent);
  --mad-accent-ring:   color-mix(in srgb, var(--main-color, #18181b) 18%, transparent);

  /* ── Info / Blue (badges, alertas informativos) ── */
  --mad-info:           #4A90D9;
  --mad-info-fg:        #ffffff;
  --mad-info-subtle:    #eff8ff;

  /* ── Secondary ── */
  --mad-secondary:        #71717a;   /* zinc-500 */
  --mad-secondary-hover:  #52525b;
  --mad-secondary-fg:     #ffffff;
  --mad-secondary-subtle: #f4f4f5;

  /* ── Semantic ── */
  --mad-success:        #16a34a;
  --mad-success-fg:     #ffffff;
  --mad-success-subtle: #f0fdf4;

  --mad-warning:        #d97706;
  --mad-warning-fg:     #ffffff;
  --mad-warning-subtle: #fffbeb;

  --mad-danger:         #dc2626;
  --mad-danger-fg:      #ffffff;
  --mad-danger-subtle:  #fef2f2;

  /* ── Radius ── */
  --mad-radius-sm:   4px;
  --mad-radius:      6px;
  --mad-radius-md:   8px;
  --mad-radius-lg:   10px;
  --mad-radius-xl:   16px;
  --mad-radius-full: 9999px;

  /* ── Shadows ── */
  --mad-shadow-sm: 0 1px 2px 0 rgba(0,0,0,.05);
  --mad-shadow:    0 1px 3px 0 rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.05);
  --mad-shadow-md: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.06);
  --mad-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.06);
  --mad-shadow-xl: 0 20px 40px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.05);

  /* ── Focus rings (sutil — estilo Notch) ── */
  --mad-ring:        rgba(0,0,0,.08);
  --mad-ring-danger: rgba(220,38,38,.15);

  /* ── Tooltip ── */
  --mad-tooltip-bg: #18181b;
  --mad-tooltip-fg: #ffffff;

  /* ── Typography ── */
  --mad-text-xs:   11px;
  --mad-text-sm:   13px;
  --mad-text-base: 14px;
  --mad-text-md:   15px;
  --mad-text-lg:   17px;
  --mad-text-xl:   20px;
  --mad-text-2xl:  24px;
  --mad-text-3xl:  30px;

  /* ── Spacing scale ── */
  --mad-s1: 4px;
  --mad-s2: 8px;
  --mad-s3: 12px;
  --mad-s4: 16px;
  --mad-s5: 20px;
  --mad-s6: 24px;
  --mad-s8: 32px;
  --mad-s10: 40px;
  --mad-s12: 48px;

  /* ── Fonts ── */
  --mad-font:      -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mad-font-mono: "JetBrains Mono", "Fira Code", "Courier New", monospace;

  /* ── Transition ── */
  --mad-t: 150ms ease;
}

/* ═══════════════════════════════════════════════════════════════════
   COLOR THEMES — Estilo shadcn/ui
   Ativado por .mad-theme-{name} no body. Combinável com layout
   variants e dark mode:
     <body class="mad-theme-blue mad-layout-float">
     <body class="mad-theme-blue mad-dark mad-layout-glass">

   Cada tema sobrescreve primary + accent + derivados.
   O default (sem classe) usa zinc (escuro — padrão Notch).
   ═══════════════════════════════════════════════════════════════════ */

/* ── Theme: Blue ── */
.mad-theme-blue,
.mad-theme-blue .mad-ui {
  --mad-primary:        #2563eb;
  --mad-primary-hover:  #1d4ed8;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #eff6ff;
  --mad-accent:         #2563eb;
  --mad-accent-subtle:  #eff6ff;
  --mad-accent-border:  rgba(37,99,235,.25);
  --mad-accent-ring:    rgba(37,99,235,.18);
  --mad-ring:           rgba(37,99,235,.12);
  --main-color:              #2563eb;
  --mad-theme-accent:      #2563eb;
  --mad-theme-rail:        #1e3a5f;
  --mad-theme-accent-dark: #1e40af;
  --menu-background-color:   #1e3a5f;
  --menu-background-check:   #2563eb;
  --menu-user-splash-background: #1e3a5f;
  --menu-border-right:       #1d4ed8;
  --field-check-color:       #2563eb;
  --modal-header-background: #1e40af;
  --top-menu-background-check: #2563eb;
  --top-menu-check-color:    #ffffff;
}
.mad-dark.mad-theme-blue,
.mad-dark.mad-theme-blue .mad-ui,
.mad-dark .mad-theme-blue .mad-ui {
  --mad-primary:        #3b82f6;
  --mad-primary-hover:  #60a5fa;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #1e3a5f;
  --mad-accent:         #3b82f6;
  --mad-accent-subtle:  color-mix(in srgb, #3b82f6 12%, #0a0a0b);
}

/* ── Theme: Violet ── */
.mad-theme-violet,
.mad-theme-violet .mad-ui {
  --mad-primary:        #7c3aed;
  --mad-primary-hover:  #6d28d9;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #f5f3ff;
  --mad-accent:         #7c3aed;
  --mad-accent-subtle:  #f5f3ff;
  --mad-accent-border:  rgba(124,58,237,.25);
  --mad-accent-ring:    rgba(124,58,237,.18);
  --mad-ring:           rgba(124,58,237,.12);
  --main-color:              #7c3aed;
  --mad-theme-accent:      #7c3aed;
  --mad-theme-rail:        #3b1a6e;
  --mad-theme-accent-dark: #5b21b6;
  --menu-background-color:   #3b1a6e;
  --menu-background-check:   #7c3aed;
  --menu-user-splash-background: #3b1a6e;
  --menu-border-right:       #6d28d9;
  --field-check-color:       #7c3aed;
  --modal-header-background: #5b21b6;
  --top-menu-background-check: #7c3aed;
  --top-menu-check-color:    #ffffff;
}
.mad-dark.mad-theme-violet,
.mad-dark.mad-theme-violet .mad-ui,
.mad-dark .mad-theme-violet .mad-ui {
  --mad-primary:        #8b5cf6;
  --mad-primary-hover:  #a78bfa;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #2e1065;
  --mad-accent:         #8b5cf6;
  --mad-accent-subtle:  color-mix(in srgb, #8b5cf6 12%, #0a0a0b);
}

/* ── Theme: Green ── */
.mad-theme-green,
.mad-theme-green .mad-ui {
  --mad-primary:        #16a34a;
  --mad-primary-hover:  #15803d;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #f0fdf4;
  --mad-accent:         #16a34a;
  --mad-accent-subtle:  #f0fdf4;
  --mad-accent-border:  rgba(22,163,74,.25);
  --mad-accent-ring:    rgba(22,163,74,.18);
  --mad-ring:           rgba(22,163,74,.12);
  --main-color:              #16a34a;
  --mad-theme-accent:      #16a34a;
  --mad-theme-rail:        #14532d;
  --mad-theme-accent-dark: #166534;
  --menu-background-color:   #14532d;
  --menu-background-check:   #16a34a;
  --menu-user-splash-background: #14532d;
  --menu-border-right:       #15803d;
  --field-check-color:       #16a34a;
  --modal-header-background: #166534;
  --top-menu-background-check: #16a34a;
  --top-menu-check-color:    #ffffff;
}
.mad-dark.mad-theme-green,
.mad-dark.mad-theme-green .mad-ui,
.mad-dark .mad-theme-green .mad-ui {
  --mad-primary:        #22c55e;
  --mad-primary-hover:  #4ade80;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #052e16;
  --mad-accent:         #22c55e;
  --mad-accent-subtle:  color-mix(in srgb, #22c55e 12%, #0a0a0b);
}

/* ── Theme: Orange ── */
.mad-theme-orange,
.mad-theme-orange .mad-ui {
  --mad-primary:        #ea580c;
  --mad-primary-hover:  #c2410c;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #fff7ed;
  --mad-accent:         #ea580c;
  --mad-accent-subtle:  #fff7ed;
  --mad-accent-border:  rgba(234,88,12,.25);
  --mad-accent-ring:    rgba(234,88,12,.18);
  --mad-ring:           rgba(234,88,12,.12);
  --main-color:              #ea580c;
  --mad-theme-accent:      #ea580c;
  --mad-theme-rail:        #7c2d12;
  --mad-theme-accent-dark: #9a3412;
  --menu-background-color:   #7c2d12;
  --menu-background-check:   #ea580c;
  --menu-user-splash-background: #7c2d12;
  --menu-border-right:       #c2410c;
  --field-check-color:       #ea580c;
  --modal-header-background: #9a3412;
  --top-menu-background-check: #ea580c;
  --top-menu-check-color:    #ffffff;
}
.mad-dark.mad-theme-orange,
.mad-dark.mad-theme-orange .mad-ui,
.mad-dark .mad-theme-orange .mad-ui {
  --mad-primary:        #f97316;
  --mad-primary-hover:  #fb923c;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #431407;
  --mad-accent:         #f97316;
  --mad-accent-subtle:  color-mix(in srgb, #f97316 12%, #0a0a0b);
}

/* ── Theme: Rose ── */
.mad-theme-rose,
.mad-theme-rose .mad-ui {
  --mad-primary:        #e11d48;
  --mad-primary-hover:  #be123c;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #fff1f2;
  --mad-accent:         #e11d48;
  --mad-accent-subtle:  #fff1f2;
  --mad-accent-border:  rgba(225,29,72,.25);
  --mad-accent-ring:    rgba(225,29,72,.18);
  --mad-ring:           rgba(225,29,72,.12);
  --main-color:              #e11d48;
  --mad-theme-accent:      #e11d48;
  --mad-theme-rail:        #881337;
  --mad-theme-accent-dark: #9f1239;
  --menu-background-color:   #881337;
  --menu-background-check:   #e11d48;
  --menu-user-splash-background: #881337;
  --menu-border-right:       #be123c;
  --field-check-color:       #e11d48;
  --modal-header-background: #9f1239;
  --top-menu-background-check: #e11d48;
  --top-menu-check-color:    #ffffff;
}
.mad-dark.mad-theme-rose,
.mad-dark.mad-theme-rose .mad-ui,
.mad-dark .mad-theme-rose .mad-ui {
  --mad-primary:        #fb7185;
  --mad-primary-hover:  #fda4af;
  --mad-primary-fg:     #1c1017;
  --mad-primary-subtle: #4c0519;
  --mad-accent:         #fb7185;
  --mad-accent-subtle:  color-mix(in srgb, #fb7185 12%, #0a0a0b);
}

/* ── Theme: Amber ── */
.mad-theme-amber,
.mad-theme-amber .mad-ui {
  --mad-primary:        #d97706;
  --mad-primary-hover:  #b45309;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #fffbeb;
  --mad-accent:         #d97706;
  --mad-accent-subtle:  #fffbeb;
  --mad-accent-border:  rgba(217,119,6,.25);
  --mad-accent-ring:    rgba(217,119,6,.18);
  --mad-ring:           rgba(217,119,6,.12);
  --main-color:              #d97706;
  --mad-theme-accent:      #d97706;
  --mad-theme-rail:        #78350f;
  --mad-theme-accent-dark: #92400e;
  --menu-background-color:   #78350f;
  --menu-background-check:   #d97706;
  --menu-user-splash-background: #78350f;
  --menu-border-right:       #b45309;
  --field-check-color:       #d97706;
  --modal-header-background: #92400e;
  --top-menu-background-check: #d97706;
  --top-menu-check-color:    #ffffff;
}
.mad-dark.mad-theme-amber,
.mad-dark.mad-theme-amber .mad-ui,
.mad-dark .mad-theme-amber .mad-ui {
  --mad-primary:        #f59e0b;
  --mad-primary-hover:  #fbbf24;
  --mad-primary-fg:     #1c1302;
  --mad-primary-subtle: #451a03;
  --mad-accent:         #f59e0b;
  --mad-accent-subtle:  color-mix(in srgb, #f59e0b 12%, #0a0a0b);
}

/* ── Theme: Slate (neutral frio) ── */
.mad-theme-slate,
.mad-theme-slate .mad-ui {
  --mad-bg:             #ffffff;
  --mad-bg-subtle:      #f8fafc;
  --mad-bg-muted:       #f1f5f9;
  --mad-border:         #e2e8f0;
  --mad-border-strong:  #cbd5e1;
  --mad-text:           #0f172a;
  --mad-text-muted:     #475569;
  --mad-text-subtle:    #94a3b8;
  --mad-primary:        #0f172a;
  --mad-primary-hover:  #1e293b;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #f1f5f9;
  --mad-accent:         #0f172a;
  --mad-accent-subtle:  #f1f5f9;
  --mad-secondary:      #64748b;
  --mad-secondary-hover:#475569;
  --main-color:              #0f172a;
  --mad-theme-accent:      #0f172a;
  --mad-theme-rail:        #0f172a;
  --mad-theme-accent-dark: #1e293b;
  --menu-background-color:   #0f172a;
  --menu-background-check:   #334155;
  --menu-user-splash-background: #0f172a;
  --menu-border-right:       #1e293b;
  --modal-header-background: #0f172a;
}
.mad-dark.mad-theme-slate,
.mad-dark.mad-theme-slate .mad-ui,
.mad-dark .mad-theme-slate .mad-ui {
  --mad-bg:             #020617;
  --mad-bg-subtle:      #0f172a;
  --mad-bg-muted:       #1e293b;
  --mad-border:         #334155;
  --mad-border-strong:  #475569;
  --mad-text:           #f8fafc;
  --mad-text-muted:     #94a3b8;
  --mad-text-subtle:    #64748b;
  --mad-primary:        #f8fafc;
  --mad-primary-hover:  #e2e8f0;
  --mad-primary-fg:     #020617;
  --mad-primary-subtle: #1e293b;
}

/* ── Theme: Stone (neutral quente) ── */
.mad-theme-stone,
.mad-theme-stone .mad-ui {
  --mad-bg:             #ffffff;
  --mad-bg-subtle:      #fafaf9;
  --mad-bg-muted:       #f5f5f4;
  --mad-border:         #e7e5e4;
  --mad-border-strong:  #d6d3d1;
  --mad-text:           #1c1917;
  --mad-text-muted:     #57534e;
  --mad-text-subtle:    #a8a29e;
  --mad-primary:        #1c1917;
  --mad-primary-hover:  #292524;
  --mad-primary-fg:     #ffffff;
  --mad-primary-subtle: #f5f5f4;
  --mad-accent:         #1c1917;
  --mad-accent-subtle:  #f5f5f4;
  --mad-secondary:      #78716c;
  --mad-secondary-hover:#57534e;
  --main-color:              #1c1917;
  --mad-theme-accent:      #1c1917;
  --mad-theme-rail:        #1c1917;
  --mad-theme-accent-dark: #292524;
  --menu-background-color:   #1c1917;
  --menu-background-check:   #44403c;
  --menu-user-splash-background: #1c1917;
  --menu-border-right:       #292524;
  --modal-header-background: #1c1917;
}
.mad-dark.mad-theme-stone,
.mad-dark.mad-theme-stone .mad-ui,
.mad-dark .mad-theme-stone .mad-ui {
  --mad-bg:             #0c0a09;
  --mad-bg-subtle:      #1c1917;
  --mad-bg-muted:       #292524;
  --mad-border:         #44403c;
  --mad-border-strong:  #57534e;
  --mad-text:           #fafaf9;
  --mad-text-muted:     #a8a29e;
  --mad-text-subtle:    #78716c;
  --mad-primary:        #fafaf9;
  --mad-primary-hover:  #e7e5e4;
  --mad-primary-fg:     #0c0a09;
  --mad-primary-subtle: #292524;
}

/* ── Dark Mode Tokens ──
   Ativado por .mad-dark no body (ou qualquer ancestral).
   Combinável com qualquer layout variant:
     <body class="mad-dark mad-layout-float">
   ────────────────────────────────────────── */

.mad-dark,
.mad-dark .mad-ui {
  --mad-bg:             #0a0a0b;
  --mad-bg-subtle:      #111113;
  --mad-bg-muted:       #18181b;

  --mad-border:         #27272a;
  --mad-border-strong:  #3f3f46;

  --mad-text:           #fafafa;
  --mad-text-muted:     #a1a1aa;
  --mad-text-subtle:    #71717a;

  --mad-primary:        #fafafa;
  --mad-primary-hover:  #e4e4e7;
  --mad-primary-fg:     #09090b;
  --mad-primary-subtle: #27272a;

  --mad-accent-subtle:  color-mix(in srgb, var(--main-color, #fafafa) 10%, #0a0a0b);
  --mad-accent-border:  color-mix(in srgb, var(--main-color, #fafafa) 20%, transparent);
  --mad-accent-ring:    color-mix(in srgb, var(--main-color, #fafafa) 14%, transparent);

  --mad-secondary:        #a1a1aa;
  --mad-secondary-hover:  #d4d4d8;
  --mad-secondary-fg:     #09090b;
  --mad-secondary-subtle: #27272a;

  --mad-info-subtle:    #0c2d48;
  --mad-success-subtle: #052e16;
  --mad-warning-subtle: #451a03;
  --mad-danger-subtle:  #450a0a;

  --mad-shadow-sm: 0 1px 2px 0 rgba(0,0,0,.3);
  --mad-shadow:    0 1px 3px 0 rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.04);
  --mad-shadow-md: 0 4px 6px -1px rgba(0,0,0,.4), 0 2px 4px -2px rgba(0,0,0,.3);
  --mad-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.4);

  --mad-ring:        rgba(255,255,255,.08);
  --mad-ring-danger: rgba(239,68,68,.25);

  color-scheme: dark;
}

/* ── Dark: Default page layout ── */
.mad-dark .mad-page-container {
  background: var(--mad-bg);
  border-color: var(--mad-border);
  box-shadow: var(--mad-shadow);
}
.mad-dark .mad-page-header {
  border-bottom-color: var(--mad-border);
}
.mad-dark .mad-page-header-icon {
  background: var(--mad-bg-muted);
  border-color: var(--mad-border);
  color: var(--mad-text-muted);
}
.mad-dark .mad-page-header-vsep {
  background: var(--mad-border);
}
.mad-dark .mad-page-breadcrumb {
  color: var(--mad-text-subtle);
}
.mad-dark .mad-page-title {
  color: var(--mad-text);
}

/* ── Dark: STRIPE ── */
.mad-dark.mad-layout-stripe .mad-page-container,
.mad-dark .mad-layout-stripe .mad-page-container {
  background: var(--mad-bg);
  box-shadow: var(--mad-shadow);
}
.mad-dark.mad-layout-stripe .mad-page-header,
.mad-dark .mad-layout-stripe .mad-page-header {
  border-bottom-color: var(--mad-border);
}
.mad-dark.mad-layout-stripe .mad-page-header-icon,
.mad-dark .mad-layout-stripe .mad-page-header-icon {
  background: color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 15%, transparent);
}

/* ── Dark: DOCK ── */
.mad-dark.mad-layout-dock .mad-page-container,
.mad-dark .mad-layout-dock .mad-page-container {
  background: var(--mad-bg);
  border-color: var(--mad-border);
  box-shadow: var(--mad-shadow);
}
.mad-dark.mad-layout-dock .mad-page-header,
.mad-dark .mad-layout-dock .mad-page-header {
  background: var(--mad-bg-muted);
}

/* ── Dark: GLASS ── */
.mad-dark.mad-layout-glass .mad-page-container,
.mad-dark .mad-layout-glass .mad-page-container {
  background:
    linear-gradient(135deg, rgba(17,17,19,.92) 0%, rgba(17,17,19,.78) 100%);
  border-color: rgba(255,255,255,.08);
  box-shadow:
    0 4px 24px rgba(0,0,0,.3),
    0 1px 2px rgba(0,0,0,.2),
    inset 0 1px 0 rgba(255,255,255,.04);
}
.mad-dark.mad-layout-glass .mad-page-header,
.mad-dark .mad-layout-glass .mad-page-header {
  background: rgba(255,255,255,.04);
  border-bottom-color: rgba(255,255,255,.06);
}
.mad-dark.mad-layout-glass .mad-page-header-icon,
.mad-dark .mad-layout-glass .mad-page-header-icon {
  background: color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 12%, transparent);
  border-color: color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 25%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 10%, transparent);
}
.mad-dark.mad-layout-glass .mad-page-header-vsep,
.mad-dark .mad-layout-glass .mad-page-header-vsep {
  background: rgba(255,255,255,.08);
}
.mad-dark.mad-layout-glass .mad-page-header-actions .mad-btn-outline,
.mad-dark .mad-layout-glass .mad-page-header-actions .mad-btn-outline {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.1);
}
.mad-dark.mad-layout-glass .mad-page-header-actions .mad-btn-outline:hover,
.mad-dark .mad-layout-glass .mad-page-header-actions .mad-btn-outline:hover {
  background: rgba(255,255,255,.12);
}

/* ── Dark: BORDER ── */
.mad-dark.mad-layout-border .mad-page-container,
.mad-dark .mad-layout-border .mad-page-container {
  background: var(--mad-bg);
  border-color: var(--mad-border);
  border-left-color: var(--mad-accent, var(--mad-primary));
}
.mad-dark.mad-layout-border .mad-page-header,
.mad-dark .mad-layout-border .mad-page-header {
  border-bottom-color: var(--mad-border);
}

/* ── Dark: INSET ── */
.mad-dark.mad-layout-inset .mad-page-container,
.mad-dark .mad-layout-inset .mad-page-container {
  background: var(--mad-bg);
  border-color: var(--mad-border);
  box-shadow: var(--mad-shadow);
}
.mad-dark.mad-layout-inset .mad-page-header,
.mad-dark .mad-layout-inset .mad-page-header {
  background:
    color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 8%, var(--mad-bg));
  border-bottom-color:
    color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 15%, transparent);
}
.mad-dark.mad-layout-inset .mad-page-content,
.mad-dark .mad-layout-inset .mad-page-content {
  background: var(--mad-bg-subtle);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.15);
}

/* ── Dark: FLOAT ── */
.mad-dark.mad-layout-float .mad-page-header,
.mad-dark .mad-layout-float .mad-page-header {
  background: var(--mad-bg);
  border-color: var(--mad-border);
  box-shadow: var(--mad-shadow);
}
.mad-dark.mad-layout-float .mad-page-content,
.mad-dark .mad-layout-float .mad-page-content {
  background: var(--mad-bg);
  border-color: var(--mad-border);
  box-shadow: var(--mad-shadow);
}

/* ═══════════════════════════════════════════════════════════════════
   2. BASE (escopo seguro dentro de .mad-ui)
   ═══════════════════════════════════════════════════════════════════ */

.mad-ui *,
.mad-ui *::before,
.mad-ui *::after { box-sizing: border-box; }

.mad-ui {
  font-family: var(--mad-font);
  font-size: var(--mad-text-base);
  color: var(--mad-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Alpine: esconde conteúdo até inicializar */
[x-cloak] { display: none !important; }


/* ═══════════════════════════════════════════════════════════════════
   3. LAYOUT
   ═══════════════════════════════════════════════════════════════════ */

.mad-flex         { display: flex; }
.mad-flex-col     { display: flex; flex-direction: column; }
.mad-flex-row     { display: flex; flex-direction: row; }
.mad-flex-wrap    { flex-wrap: wrap; }
.mad-flex-nowrap  { flex-wrap: nowrap; }
.mad-flex-1       { flex: 1 1 0%; }
.mad-flex-auto    { flex: 1 1 auto; }
.mad-flex-none    { flex: none; }
.mad-shrink-0     { flex-shrink: 0; }
.mad-grow         { flex-grow: 1; }
.mad-grow-0       { flex-grow: 0; }

.mad-items-start    { align-items: flex-start; }
.mad-items-center   { align-items: center; }
.mad-items-end      { align-items: flex-end; }
.mad-items-stretch  { align-items: stretch; }
.mad-items-baseline { align-items: baseline; }

.mad-justify-start   { justify-content: flex-start; }
.mad-justify-center  { justify-content: center; }
.mad-justify-end     { justify-content: flex-end; }
.mad-justify-between { justify-content: space-between; }
.mad-justify-around  { justify-content: space-around; }
.mad-justify-evenly  { justify-content: space-evenly; }

.mad-grid          { display: grid; }
.mad-grid-cols-2   { grid-template-columns: repeat(2, 1fr); }
.mad-grid-cols-3   { grid-template-columns: repeat(3, 1fr); }
.mad-grid-cols-4   { grid-template-columns: repeat(4, 1fr); }
.mad-col-span-2    { grid-column: span 2; }
.mad-col-span-3    { grid-column: span 3; }
.mad-col-full      { grid-column: 1 / -1; }

/* Stack — coluna com gap fixo */
.mad-stack   { display: flex; flex-direction: column; }
.mad-stack-1 { display: flex; flex-direction: column; gap: var(--mad-s1); }
.mad-stack-2 { display: flex; flex-direction: column; gap: var(--mad-s2); }
.mad-stack-3 { display: flex; flex-direction: column; gap: var(--mad-s3); }
.mad-stack-4 { display: flex; flex-direction: column; gap: var(--mad-s4); }
.mad-stack-6 { display: flex; flex-direction: column; gap: var(--mad-s6); }

/* Cluster — linha com wrap */
.mad-cluster { display: flex; flex-wrap: wrap; gap: var(--mad-s2); align-items: center; }


/* ═══════════════════════════════════════════════════════════════════
   4. ESPAÇAMENTO
   ═══════════════════════════════════════════════════════════════════ */

/* Gap */
.mad-gap-0  { gap: 0; }
.mad-gap-1  { gap: var(--mad-s1); }
.mad-gap-2  { gap: var(--mad-s2); }
.mad-gap-3  { gap: var(--mad-s3); }
.mad-gap-4  { gap: var(--mad-s4); }
.mad-gap-5  { gap: var(--mad-s5); }
.mad-gap-6  { gap: var(--mad-s6); }
.mad-gap-8  { gap: var(--mad-s8); }

/* Padding */
.mad-p-0  { padding: 0; }
.mad-p-1  { padding: var(--mad-s1); }
.mad-p-2  { padding: var(--mad-s2); }
.mad-p-3  { padding: var(--mad-s3); }
.mad-p-4  { padding: var(--mad-s4); }
.mad-p-5  { padding: var(--mad-s5); }
.mad-p-6  { padding: var(--mad-s6); }
.mad-p-8  { padding: var(--mad-s8); }

.mad-px-0 { padding-left: 0; padding-right: 0; }
.mad-px-1 { padding-left: var(--mad-s1); padding-right: var(--mad-s1); }
.mad-px-2 { padding-left: var(--mad-s2); padding-right: var(--mad-s2); }
.mad-px-3 { padding-left: var(--mad-s3); padding-right: var(--mad-s3); }
.mad-px-4 { padding-left: var(--mad-s4); padding-right: var(--mad-s4); }
.mad-px-5 { padding-left: var(--mad-s5); padding-right: var(--mad-s5); }
.mad-px-6 { padding-left: var(--mad-s6); padding-right: var(--mad-s6); }

.mad-py-0 { padding-top: 0; padding-bottom: 0; }
.mad-py-1 { padding-top: var(--mad-s1); padding-bottom: var(--mad-s1); }
.mad-py-2 { padding-top: var(--mad-s2); padding-bottom: var(--mad-s2); }
.mad-py-3 { padding-top: var(--mad-s3); padding-bottom: var(--mad-s3); }
.mad-py-4 { padding-top: var(--mad-s4); padding-bottom: var(--mad-s4); }
.mad-py-5 { padding-top: var(--mad-s5); padding-bottom: var(--mad-s5); }
.mad-py-6 { padding-top: var(--mad-s6); padding-bottom: var(--mad-s6); }

.mad-pt-0 { padding-top: 0; }    .mad-pt-1 { padding-top: var(--mad-s1); }
.mad-pt-2 { padding-top: var(--mad-s2); } .mad-pt-3 { padding-top: var(--mad-s3); }
.mad-pt-4 { padding-top: var(--mad-s4); } .mad-pt-6 { padding-top: var(--mad-s6); }

.mad-pb-0 { padding-bottom: 0; }  .mad-pb-1 { padding-bottom: var(--mad-s1); }
.mad-pb-2 { padding-bottom: var(--mad-s2); } .mad-pb-3 { padding-bottom: var(--mad-s3); }
.mad-pb-4 { padding-bottom: var(--mad-s4); } .mad-pb-6 { padding-bottom: var(--mad-s6); }

.mad-pl-0 { padding-left: 0; } .mad-pl-2 { padding-left: var(--mad-s2); }
.mad-pl-4 { padding-left: var(--mad-s4); } .mad-pl-6 { padding-left: var(--mad-s6); }

.mad-pr-0 { padding-right: 0; } .mad-pr-2 { padding-right: var(--mad-s2); }
.mad-pr-4 { padding-right: var(--mad-s4); } .mad-pr-6 { padding-right: var(--mad-s6); }

/* Margin */
.mad-m-0    { margin: 0; }
.mad-m-auto { margin: auto; }
.mad-mx-auto { margin-left: auto; margin-right: auto; }
.mad-ml-auto { margin-left: auto; }
.mad-mr-auto { margin-right: auto; }

.mad-mt-0 { margin-top: 0; }    .mad-mt-1 { margin-top: var(--mad-s1); }
.mad-mt-2 { margin-top: var(--mad-s2); } .mad-mt-3 { margin-top: var(--mad-s3); }
.mad-mt-4 { margin-top: var(--mad-s4); } .mad-mt-5 { margin-top: var(--mad-s5); }
.mad-mt-6 { margin-top: var(--mad-s6); } .mad-mt-8 { margin-top: var(--mad-s8); }

.mad-mb-0 { margin-bottom: 0; }  .mad-mb-1 { margin-bottom: var(--mad-s1); }
.mad-mb-2 { margin-bottom: var(--mad-s2); } .mad-mb-3 { margin-bottom: var(--mad-s3); }
.mad-mb-4 { margin-bottom: var(--mad-s4); } .mad-mb-6 { margin-bottom: var(--mad-s6); }
.mad-mb-8 { margin-bottom: var(--mad-s8); }


/* ═══════════════════════════════════════════════════════════════════
   5. TIPOGRAFIA
   ═══════════════════════════════════════════════════════════════════ */

.mad-text-xs   { font-size: var(--mad-text-xs); }
.mad-text-sm   { font-size: var(--mad-text-sm); }
.mad-text-base { font-size: var(--mad-text-base); }
.mad-text-md   { font-size: var(--mad-text-md); }
.mad-text-lg   { font-size: var(--mad-text-lg); }
.mad-text-xl   { font-size: var(--mad-text-xl); }
.mad-text-2xl  { font-size: var(--mad-text-2xl); }
.mad-text-3xl  { font-size: var(--mad-text-3xl); }

.mad-font-normal   { font-weight: 400; }
.mad-font-medium   { font-weight: 500; }
.mad-font-semibold { font-weight: 600; }
.mad-font-bold     { font-weight: 700; }

.mad-text-left   { text-align: left; }
.mad-text-center { text-align: center; }
.mad-text-right  { text-align: right; }

.mad-uppercase   { text-transform: uppercase; }
.mad-lowercase   { text-transform: lowercase; }
.mad-capitalize  { text-transform: capitalize; }
.mad-normal-case { text-transform: none; }

.mad-tracking-tight  { letter-spacing: -.025em; }
.mad-tracking-normal { letter-spacing: 0; }
.mad-tracking-wide   { letter-spacing: .05em; }
.mad-tracking-wider  { letter-spacing: .1em; }

.mad-leading-none    { line-height: 1; }
.mad-leading-tight   { line-height: 1.25; }
.mad-leading-normal  { line-height: 1.5; }
.mad-leading-relaxed { line-height: 1.7; }

.mad-truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mad-whitespace-nowrap { white-space: nowrap; }
.mad-break-words  { word-break: break-word; overflow-wrap: break-word; }
.mad-line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mad-line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.mad-mono { font-family: var(--mad-font-mono); }

/* Cores de texto */
.mad-text-primary   { color: var(--mad-primary); }
.mad-text-secondary { color: var(--mad-secondary); }
.mad-text-muted     { color: var(--mad-text-muted); }
.mad-text-subtle    { color: var(--mad-text-subtle); }
.mad-text-success   { color: var(--mad-success); }
.mad-text-warning   { color: var(--mad-warning); }
.mad-text-danger    { color: var(--mad-danger); }
.mad-text-white     { color: #fff; }


/* ═══════════════════════════════════════════════════════════════════
   6. BACKGROUND
   ═══════════════════════════════════════════════════════════════════ */

.mad-bg-white           { background-color: var(--mad-bg); }
.mad-bg-subtle          { background-color: var(--mad-bg-subtle); }
.mad-bg-muted           { background-color: var(--mad-bg-muted); }
.mad-bg-primary         { background-color: var(--mad-primary); }
.mad-bg-primary-subtle  { background-color: var(--mad-primary-subtle); }
.mad-bg-success-subtle  { background-color: var(--mad-success-subtle); }
.mad-bg-warning-subtle  { background-color: var(--mad-warning-subtle); }
.mad-bg-danger-subtle   { background-color: var(--mad-danger-subtle); }
.mad-bg-transparent     { background-color: transparent; }


/* ═══════════════════════════════════════════════════════════════════
   7. BORDAS E RADIUS
   ═══════════════════════════════════════════════════════════════════ */

.mad-border         { border: 1.5px solid var(--mad-border); }
.mad-border-0       { border: none; }
.mad-border-t       { border-top: 1.5px solid var(--mad-border); }
.mad-border-b       { border-bottom: 1.5px solid var(--mad-border); }
.mad-border-l       { border-left: 1.5px solid var(--mad-border); }
.mad-border-r       { border-right: 1.5px solid var(--mad-border); }
.mad-border-strong  { border-color: var(--mad-border-strong) !important; }
.mad-border-primary { border-color: var(--mad-primary) !important; }
.mad-border-danger  { border-color: var(--mad-danger) !important; }

.mad-rounded-none { border-radius: 0; }
.mad-rounded-sm   { border-radius: var(--mad-radius-sm); }
.mad-rounded      { border-radius: var(--mad-radius); }
.mad-rounded-md   { border-radius: var(--mad-radius-md); }
.mad-rounded-lg   { border-radius: var(--mad-radius-lg); }
.mad-rounded-xl   { border-radius: var(--mad-radius-xl); }
.mad-rounded-full { border-radius: var(--mad-radius-full); }


/* ═══════════════════════════════════════════════════════════════════
   8. SOMBRAS
   ═══════════════════════════════════════════════════════════════════ */

.mad-shadow-none { box-shadow: none; }
.mad-shadow-sm   { box-shadow: var(--mad-shadow-sm); }
.mad-shadow      { box-shadow: var(--mad-shadow); }
.mad-shadow-md   { box-shadow: var(--mad-shadow-md); }
.mad-shadow-lg   { box-shadow: var(--mad-shadow-lg); }


/* ═══════════════════════════════════════════════════════════════════
   9. DISPLAY, POSIÇÃO, OVERFLOW
   ═══════════════════════════════════════════════════════════════════ */

.mad-hidden        { display: none !important; }

/* Read-only visual para campos que não têm `readonly` nativo (select, checkbox, radio, switch).
   O valor continua sendo enviado no POST — por isso não usamos `disabled`. */
.mad-readonly,
.mad-readonly-select {
    pointer-events: none;
    opacity: 0.75;
}
.mad-readonly-select {
    background-color: var(--mad-muted, #f3f4f6);
}

.mad-block         { display: block; }
.mad-inline        { display: inline; }
.mad-inline-block  { display: inline-block; }
.mad-inline-flex   { display: inline-flex; }
.mad-contents      { display: contents; }

.mad-relative { position: relative; }
.mad-absolute { position: absolute; }
.mad-fixed    { position: fixed; }
.mad-sticky   { position: sticky; }
.mad-inset-0  { inset: 0; }
.mad-top-0    { top: 0; }
.mad-right-0  { right: 0; }
.mad-bottom-0 { bottom: 0; }
.mad-left-0   { left: 0; }

.mad-overflow-hidden   { overflow: hidden; }
.mad-overflow-auto     { overflow: auto; }
.mad-overflow-y-auto   { overflow-y: auto; }
.mad-overflow-x-auto   { overflow-x: auto; }

.mad-w-full    { width: 100%; }
.mad-w-auto    { width: auto; }
.mad-w-fit     { width: fit-content; }
.mad-w-screen  { width: 100vw; }
.mad-h-full    { height: 100%; }
.mad-h-auto    { height: auto; }
.mad-h-fit     { height: fit-content; }
.mad-h-screen  { height: 100vh; }
.mad-min-w-0   { min-width: 0; }
.mad-min-h-0   { min-height: 0; }
.mad-max-w-xs  { max-width: 320px; }
.mad-max-w-sm  { max-width: 480px; }
.mad-max-w-md  { max-width: 640px; }
.mad-max-w-lg  { max-width: 800px; }
.mad-max-w-xl  { max-width: 1024px; }
.mad-max-w-full{ max-width: 100%; }

.mad-z-0   { z-index: 0; }
.mad-z-10  { z-index: 10; }
.mad-z-20  { z-index: 20; }
.mad-z-50  { z-index: 50; }

.mad-opacity-0   { opacity: 0; }
.mad-opacity-25  { opacity: .25; }
.mad-opacity-50  { opacity: .5; }
.mad-opacity-75  { opacity: .75; }
.mad-opacity-100 { opacity: 1; }

.mad-cursor-pointer     { cursor: pointer; }
.mad-cursor-default     { cursor: default; }
.mad-cursor-not-allowed { cursor: not-allowed; }
.mad-cursor-move        { cursor: move; }

.mad-select-none    { user-select: none; }
.mad-select-all     { user-select: all; }
.mad-pointer-none   { pointer-events: none; }

.mad-transition      { transition: all var(--mad-t); }
.mad-transition-none { transition: none; }

.mad-sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.mad-list-none { list-style: none; margin: 0; padding: 0; }
.mad-no-underline { text-decoration: none; }


/* ═══════════════════════════════════════════════════════════════════
   10. COMPONENTE — BUTTON
   ═══════════════════════════════════════════════════════════════════ */

.mad-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px solid transparent;
  border-radius: var(--mad-radius);
  padding: 8px 16px;
  font-size: var(--mad-text-sm);
  font-family: var(--mad-font);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
  vertical-align: middle;
  background: transparent;
  color: inherit;
  transition: background var(--mad-t), border-color var(--mad-t),
              color var(--mad-t), opacity var(--mad-t), box-shadow var(--mad-t);
}
.mad-btn:focus-visible {
  outline: 2px solid var(--mad-primary);
  outline-offset: 2px;
}
.mad-btn:disabled,
.mad-btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Variantes */
.mad-btn-default {
  background: var(--mad-text);
  color: var(--mad-bg);
  border-color: var(--mad-text);
}
.mad-btn-default:hover { opacity: .85; }

.mad-btn-primary {
  background: var(--mad-primary);
  color: var(--mad-primary-fg);
  border-color: var(--mad-primary);
}
.mad-btn-primary:hover {
  background: var(--mad-primary-hover);
  border-color: var(--mad-primary-hover);
}

.mad-btn-secondary {
  background: var(--mad-bg-muted);
  color: var(--mad-text);
  border-color: var(--mad-border);
}
.mad-btn-secondary:hover { background: var(--mad-border); }

.mad-btn-outline {
  background: transparent;
  color: var(--mad-text);
  border-color: var(--mad-border-strong);
}
.mad-btn-outline:hover { background: var(--mad-bg-subtle); }

.mad-btn-ghost {
  background: transparent;
  color: var(--mad-text);
  border-color: transparent;
}
.mad-btn-ghost:hover { background: var(--mad-bg-muted); }

.mad-btn-danger,
.mad-btn-destructive {
  background: var(--mad-danger, #ef4444);
  color: var(--mad-danger-fg, #fff);
  border-color: var(--mad-danger, #ef4444);
}
.mad-btn-danger:hover,
.mad-btn-destructive:hover {
  background: color-mix(in srgb, var(--mad-danger, #ef4444) 85%, #000);
  border-color: color-mix(in srgb, var(--mad-danger, #ef4444) 85%, #000);
}

.mad-btn-success {
  background: var(--mad-success, #22c55e);
  color: var(--mad-success-fg, #fff);
  border-color: var(--mad-success, #22c55e);
}
.mad-btn-success:hover {
  background: color-mix(in srgb, var(--mad-success, #22c55e) 85%, #000);
  border-color: color-mix(in srgb, var(--mad-success, #22c55e) 85%, #000);
}

.mad-btn-warning {
  background: var(--mad-warning, #f59e0b);
  color: var(--mad-warning-fg, #fff);
  border-color: var(--mad-warning, #f59e0b);
}
.mad-btn-warning:hover {
  background: color-mix(in srgb, var(--mad-warning, #f59e0b) 85%, #000);
  border-color: color-mix(in srgb, var(--mad-warning, #f59e0b) 85%, #000);
}

.mad-btn-info {
  background: var(--mad-info, #3b82f6);
  color: var(--mad-info-fg, #fff);
  border-color: var(--mad-info, #3b82f6);
}
.mad-btn-info:hover {
  background: color-mix(in srgb, var(--mad-info, #3b82f6) 85%, #000);
  border-color: color-mix(in srgb, var(--mad-info, #3b82f6) 85%, #000);
}

/* Outline variants */
.mad-btn-outline-danger {
  background: transparent;
  color: var(--mad-danger, #ef4444);
  border-color: var(--mad-danger, #ef4444);
}
.mad-btn-outline-danger:hover { background: color-mix(in srgb, var(--mad-danger, #ef4444) 10%, transparent); }

.mad-btn-outline-success {
  background: transparent;
  color: var(--mad-success, #22c55e);
  border-color: var(--mad-success, #22c55e);
}
.mad-btn-outline-success:hover { background: color-mix(in srgb, var(--mad-success, #22c55e) 10%, transparent); }

.mad-btn-outline-warning {
  background: transparent;
  color: var(--mad-warning, #f59e0b);
  border-color: var(--mad-warning, #f59e0b);
}
.mad-btn-outline-warning:hover { background: color-mix(in srgb, var(--mad-warning, #f59e0b) 10%, transparent); }

.mad-btn-outline-primary {
  background: transparent;
  color: var(--mad-primary);
  border-color: var(--mad-primary);
}
.mad-btn-outline-primary:hover { background: color-mix(in srgb, var(--mad-primary) 10%, transparent); }

.mad-btn-link {
  background: transparent;
  color: var(--mad-primary);
  border-color: transparent;
  text-decoration: underline;
  padding-left: 0;
  padding-right: 0;
}
.mad-btn-link:hover { opacity: .75; }

/* Tamanhos */
.mad-btn-sm {
  padding: 5px 10px;
  font-size: var(--mad-text-xs);
  border-radius: var(--mad-radius-sm);
  gap: 4px;
}
.mad-btn-lg {
  padding: 11px 22px;
  font-size: var(--mad-text-md);
  border-radius: var(--mad-radius-md);
  gap: 8px;
}
.mad-btn-icon {
  padding: 0;
  width: 36px;
  height: 36px;
}
.mad-btn-icon.mad-btn-sm { width: 28px; height: 28px; }
.mad-btn-icon.mad-btn-lg { width: 44px; height: 44px; }
.mad-btn-block { width: 100%; }


/* ═══════════════════════════════════════════════════════════════════
   11. COMPONENTE — INPUT / SELECT / TEXTAREA
   ═══════════════════════════════════════════════════════════════════ */

.mad-input,
.mad-textarea {
  display: block;
  width: 100%;
  border: 1.5px solid var(--mad-border);
  border-radius: var(--mad-radius);
  padding: 8px 12px;
  font-size: var(--mad-text-sm);
  font-family: var(--mad-font);
  color: var(--mad-text);
  background: var(--mad-bg);
  line-height: 1.5;
  box-sizing: border-box;
  transition: border-color var(--mad-t), box-shadow var(--mad-t);
}
.mad-input:focus,
.mad-select:focus,
.mad-textarea:focus {
  outline: none;
  border-color: var(--mad-primary);
  box-shadow: 0 0 0 3px var(--mad-ring);
}
.mad-input::placeholder,
.mad-textarea::placeholder { color: var(--mad-text-subtle); }
.mad-input:disabled,
.mad-select:disabled,
.mad-textarea:disabled {
  opacity: .5;
  cursor: not-allowed;
  background: var(--mad-bg-subtle);
}
input.mad-input:read-only,
textarea.mad-input:read-only,
textarea.mad-textarea:read-only {
  background: var(--mad-bg-subtle);
  cursor: default;
  border-color: var(--mad-border);
}
input.mad-input:read-only:focus,
textarea.mad-input:read-only:focus,
textarea.mad-textarea:read-only:focus {
  box-shadow: none;
  border-color: var(--mad-border);
}

.mad-input-error,
.mad-select-error,
.mad-textarea-error {
  border-color: var(--mad-danger) !important;
  box-shadow: 0 0 0 3px var(--mad-ring-danger) !important;
}

.mad-textarea  { resize: vertical; min-height: 80px; }
.mad-input-sm,
.mad-select-sm { padding: 5px 8px; font-size: var(--mad-text-xs); border-radius: var(--mad-radius-sm); }
.mad-input-lg  { padding: 10px 14px; font-size: var(--mad-text-base); }
.mad-input-mono{ font-family: var(--mad-font-mono); font-size: 12px; letter-spacing: .5px; }

/* ── Tom Select — overrides visuais (bordas, cores, raio, padding) ─── */

.ts-control {
  border: 1px solid var(--mad-border) !important;
  border-radius: var(--mad-radius) !important;
  padding: 6px 8px !important;
  background-color: var(--mad-bg) !important;
  color: var(--mad-text);
  font-family: var(--mad-font);
  font-size: var(--mad-text-sm);
  box-shadow: none !important;
}
.focus .ts-control {
  border-color: var(--mad-border-strong) !important;
  box-shadow: 0 0 0 3px rgba(0,0,0,.06) !important;
}
/* Quando buscando: esconde o item para o input ocupar o lugar */
.ts-wrapper.single.dropdown-active .ts-control .item {
  display: none;
}
/* Altura do input de busca — anula height fixo do Bootstrap */
.ts-control > input {
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
  padding: 0 !important;
  line-height: 1.5 !important;
  border-radius: 0 !important;
}
.disabled .ts-control {
  background-color: var(--mad-bg-subtle) !important;
}

.ts-dropdown {
  border: 1px solid var(--mad-border) !important;
  border-top: 1px solid var(--mad-border) !important;
  border-radius: var(--mad-radius) !important;
  box-shadow: var(--mad-shadow-lg) !important;
  background: var(--mad-bg) !important;
}
.ts-dropdown .active {
  background-color: var(--mad-bg-muted) !important;
  color: var(--mad-text) !important;
}

.ts-wrapper:not(.form-control,.form-select).single .ts-control {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right .75rem center;
  background-repeat: no-repeat;
  background-size: 16px 12px;
}

/* Erro */
.mad-ts-error .ts-control {
  border-color: var(--mad-danger) !important;
  box-shadow: 0 0 0 3px var(--mad-ring-danger) !important;
}

/* ═══════════════════════════════════════════════════════════════════
   Select Check — multi-select com checkboxes + display condensado
   (mad-select-check-field / mad-dbselect-check-field)
   ═══════════════════════════════════════════════════════════════════ */
.mad-bsc-wrap .ts-control {
  flex-wrap: nowrap;
  overflow: hidden;
  white-space: nowrap;
}
.mad-bsc-wrap .ts-control .mad-bsc-chip {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 2px 0 0 !important;
  color: var(--mad-text) !important;
  font-weight: normal !important;
  box-shadow: none !important;
  cursor: default;
}
.mad-bsc-wrap .ts-control .mad-bsc-chip.mad-bsc-comma::after {
  content: ",";
  margin-right: 2px;
}
.mad-bsc-wrap .ts-control .mad-bsc-more {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  margin-left: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--mad-primary, #3b82f6);
  background: var(--mad-bg-subtle, #f1f5f9);
  border-radius: 10px;
  white-space: nowrap;
}

/* Checkbox nativo dentro do dropdown (plugin checkbox_options) */
.mad-bsc-wrap.ts-wrapper .ts-dropdown .option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
}
.mad-bsc-wrap.ts-wrapper .ts-dropdown .option input[type="checkbox"] {
  /* theme-notch aplica appearance:none + ::before quadrado preto global.
     Aqui forcamos o checkbox nativo de volta e desativamos o ::before. */
  -webkit-appearance: checkbox !important;
  -moz-appearance: checkbox !important;
  appearance: checkbox !important;
  margin: 0 !important;
  padding: 0 !important;
  cursor: pointer;
  width: 16px !important;
  height: 16px !important;
  min-width: 16px;
  border: none !important;
  border-radius: 0 !important;
  background: initial !important;
  flex-shrink: 0;
  accent-color: var(--mad-primary, #3b82f6);
}
.mad-bsc-wrap.ts-wrapper .ts-dropdown .option input[type="checkbox"]::before,
.mad-bsc-wrap.ts-wrapper .ts-dropdown .option input[type="checkbox"]::after {
  content: none !important;
  display: none !important;
  background: none !important;
  transform: none !important;
}


/* ═══════════════════════════════════════════════════════════════════
   12. COMPONENTE — FIELD (label + input + hint)
   ═══════════════════════════════════════════════════════════════════ */

.mad-field   { display: flex; flex-direction: column; gap: 5px; }
.mad-label   { font-size: var(--mad-text-xs); font-weight: 700; color: var(--mad-text); }
.mad-label-required::after { content: ' *'; color: var(--mad-danger); }
.mad-hint    { font-size: var(--mad-text-xs); color: var(--mad-text-subtle); line-height: 1.5; }
.mad-error   { font-size: var(--mad-text-xs); color: var(--mad-danger); }


/* ═══════════════════════════════════════════════════════════════════
   13. COMPONENTE — CARD
   ═══════════════════════════════════════════════════════════════════ */

.mad-card {
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-lg);
  box-shadow: var(--mad-shadow-sm);
}

.mad-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--mad-s4) var(--mad-s5);
  border-bottom: 1px solid var(--mad-border);
}

.mad-card-title {
  font-size: var(--mad-text-base);
  font-weight: 700;
  color: var(--mad-text);
  line-height: 1.3;
}

.mad-card-description {
  font-size: var(--mad-text-sm);
  color: var(--mad-text-muted);
  margin-top: 2px;
  line-height: 1.5;
}

.mad-card-content { padding: var(--mad-s5); }
.mad-card-content + .mad-card-content { padding-top: 0; }

.mad-card-footer {
  padding: var(--mad-s3) var(--mad-s5);
  border-top: 1px solid var(--mad-border);
  background: var(--mad-bg-subtle);
  display: flex;
  align-items: center;
  gap: var(--mad-s2);
}


/* ═══════════════════════════════════════════════════════════════════
   14. COMPONENTE — BADGE
   ═══════════════════════════════════════════════════════════════════ */

.mad-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--mad-radius-full);
  font-size: var(--mad-text-xs);
  font-weight: 600;
  line-height: 1.6;
  border: 1px solid transparent;
  white-space: nowrap;
}

.mad-badge-default   { background: var(--mad-text); color: var(--mad-bg); }
.mad-badge-secondary { background: var(--mad-bg-muted); color: var(--mad-text-muted); border-color: var(--mad-border); }
.mad-badge-outline   { background: transparent; color: var(--mad-text); border-color: var(--mad-border-strong); }
.mad-badge-primary   { background: var(--mad-primary-subtle); color: var(--mad-text-muted); border-color: var(--mad-border); }
.mad-badge-info      { background: var(--mad-info-subtle); color: var(--mad-info); border-color: rgba(74,144,217,.3); }
.mad-badge-success   { background: var(--mad-success-subtle); color: var(--mad-success); border-color: rgba(22,163,74,.3); }
.mad-badge-warning   { background: var(--mad-warning-subtle); color: var(--mad-warning); border-color: rgba(217,119,6,.3); }
.mad-badge-danger    { background: var(--mad-danger-subtle);  color: var(--mad-danger);  border-color: rgba(220,38,38,.3); }

.mad-badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}


/* ═══════════════════════════════════════════════════════════════════
   15. COMPONENTE — ALERT
   ═══════════════════════════════════════════════════════════════════ */

.mad-alert {
  display: flex;
  gap: var(--mad-s3);
  padding: var(--mad-s3) var(--mad-s4);
  border-radius: var(--mad-radius);
  border: 1px solid var(--mad-border);
  background: var(--mad-bg-subtle);
  font-size: var(--mad-text-sm);
}

.mad-alert-icon  { flex-shrink: 0; font-size: 16px; margin-top: 1px; }
.mad-alert-title { font-weight: 700; margin-bottom: 2px; }
.mad-alert-desc  { color: var(--mad-text-muted); line-height: 1.5; }

.mad-alert-info    { border-color: rgba(74,144,217,.35); background: var(--mad-info-subtle); color: #1a3a5c; }
.mad-alert-success { border-color: rgba(22,163,74,.35);  background: var(--mad-success-subtle); color: #14532d; }
.mad-alert-warning { border-color: rgba(217,119,6,.35);  background: var(--mad-warning-subtle); color: #78350f; }
.mad-alert-danger  { border-color: rgba(220,38,38,.35);  background: var(--mad-danger-subtle);  color: #7f1d1d; }


/* ═══════════════════════════════════════════════════════════════════
   16. COMPONENTE — TOGGLE (switch)
   ═══════════════════════════════════════════════════════════════════ */

.mad-toggle-wrap { display: inline-flex; align-items: center; gap: var(--mad-s2); cursor: pointer; }
.mad-toggle      { position: relative; display: inline-flex; width: 40px; height: 22px; flex-shrink: 0; }
.mad-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.mad-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--mad-border-strong);
  border-radius: var(--mad-radius-full);
  cursor: pointer;
  transition: background var(--mad-t);
}
.mad-toggle-track::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--mad-t);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.mad-toggle input:checked  ~ .mad-toggle-track { background: var(--mad-success); }
.mad-toggle input:checked  ~ .mad-toggle-track::before { transform: translateX(18px); }
.mad-toggle input:focus-visible ~ .mad-toggle-track { outline: 2px solid var(--mad-primary); outline-offset: 2px; }
.mad-toggle input:disabled ~ .mad-toggle-track { opacity: .5; cursor: not-allowed; }

/* Variants de cor (sobrescreve track quando checked) */
.mad-toggle--primary input:checked ~ .mad-toggle-track { background: var(--mad-primary); }
.mad-toggle--success input:checked ~ .mad-toggle-track { background: var(--mad-success); }
.mad-toggle--warning input:checked ~ .mad-toggle-track { background: var(--mad-warning); }
.mad-toggle--danger  input:checked ~ .mad-toggle-track { background: var(--mad-danger); }
.mad-toggle--info    input:checked ~ .mad-toggle-track { background: var(--mad-info); }

/* Sizes */
.mad-toggle--sm { width: 32px; height: 18px; }
.mad-toggle--sm .mad-toggle-track::before { width: 12px; height: 12px; left: 3px; top: 3px; }
.mad-toggle--sm input:checked ~ .mad-toggle-track::before { transform: translateX(14px); }

.mad-toggle--lg { width: 56px; height: 30px; }
.mad-toggle--lg .mad-toggle-track::before { width: 24px; height: 24px; left: 3px; top: 3px; }
.mad-toggle--lg input:checked ~ .mad-toggle-track::before { transform: translateX(26px); }

/* Switch row / card */
.mad-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.mad-switch-card {
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius);
  padding: 14px 16px;
}
.mad-switch-text { flex: 1; min-width: 0; }
.mad-switch-desc {
  font-size: 0.82rem;
  color: var(--mad-text-muted);
  margin-top: 2px;
  line-height: 1.4;
}


/* ═══════════════════════════════════════════════════════════════════
   17. COMPONENTE — AVATAR
   ═══════════════════════════════════════════════════════════════════ */

.mad-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--mad-radius-full);
  background: var(--mad-bg-muted);
  color: var(--mad-text-muted);
  font-size: var(--mad-text-sm);
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
}
.mad-avatar img      { width: 100%; height: 100%; object-fit: cover; }
.mad-avatar-sm       { width: 28px; height: 28px; font-size: var(--mad-text-xs); }
.mad-avatar-lg       { width: 48px; height: 48px; font-size: var(--mad-text-lg); }
.mad-avatar-xl       { width: 64px; height: 64px; font-size: var(--mad-text-xl); }
.mad-avatar-primary  { background: var(--mad-primary-subtle); color: var(--mad-primary); }
.mad-avatar-success  { background: var(--mad-success-subtle); color: var(--mad-success); }

/* Avatar group */
.mad-avatar-group { display: inline-flex; }
.mad-avatar-group .mad-avatar { border: 2px solid var(--mad-bg); }
.mad-avatar-group .mad-avatar + .mad-avatar { margin-left: -10px; }


/* ═══════════════════════════════════════════════════════════════════
   18. COMPONENTE — TABS
   ═══════════════════════════════════════════════════════════════════ */

.mad-tabs { display: flex; flex-direction: column; }

.mad-tabs-list {
  display: inline-flex;
  background: var(--mad-bg-muted);
  border-radius: var(--mad-radius);
  padding: 3px;
  gap: 2px;
}

.mad-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: calc(var(--mad-radius) - 2px);
  font-size: var(--mad-text-sm);
  font-weight: 500;
  color: var(--mad-text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: color var(--mad-t), background var(--mad-t), box-shadow var(--mad-t);
  white-space: nowrap;
  user-select: none;
}
.mad-tab:hover { color: var(--mad-text); background: rgba(0,0,0,.05); }

.mad-tab-active,
.mad-tab[aria-selected="true"] {
  background: var(--mad-bg);
  color: var(--mad-text);
  box-shadow: var(--mad-shadow-sm);
  font-weight: 600;
}

.mad-tab-content { margin-top: var(--mad-s4); }

/* Tabs underline (variante) */
.mad-tabs-underline .mad-tabs-list {
  background: transparent;
  border-radius: 0;
  padding: 0;
  border-bottom: 2px solid var(--mad-border);
}
.mad-tabs-underline .mad-tab {
  border-radius: 0;
  padding: 8px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.mad-tabs-underline .mad-tab-active,
.mad-tabs-underline .mad-tab[aria-selected="true"] {
  background: transparent;
  box-shadow: none;
  border-bottom-color: var(--mad-primary);
  color: var(--mad-primary);
}

/* Tabs vertical (sidebar variant) */
.mad-tabs-vertical {
  flex-direction: row;
  gap: 32px;
  align-items: flex-start;
}

.mad-tabs-vertical .mad-tabs-list {
  flex-direction: column;
  width: 220px;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-lg, 8px);
  padding: 4px;
  gap: 2px;
}

.mad-tabs-vertical .mad-tab {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  padding: 8px 12px;
  border-radius: calc(var(--mad-radius-lg, 8px) - 2px);
  font-size: 14px;
}

.mad-tabs-vertical .mad-tab:hover:not(:disabled) {
  background: var(--mad-bg-muted);
}

.mad-tabs-vertical .mad-tab-active,
.mad-tabs-vertical .mad-tab[aria-selected="true"] {
  background: var(--mad-bg-muted);
  box-shadow: none;
  font-weight: 500;
}

.mad-tabs-vertical .mad-tab-content {
  flex: 1;
  min-width: 0;
  max-width: 640px;
  margin-top: 0;
}

@media (max-width: 768px) {
  .mad-tabs-vertical { flex-direction: column; gap: 16px; }
  .mad-tabs-vertical .mad-tabs-list {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }
  .mad-tabs-vertical .mad-tab { width: auto; flex: 0 0 auto; }
  .mad-tabs-vertical .mad-tab-content { max-width: 100%; }
}

/* Tab disabled */
.mad-tab:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}


/* ═══════════════════════════════════════════════════════════════════
   19. COMPONENTE — TABLE
   ═══════════════════════════════════════════════════════════════════ */

.mad-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-lg);
}

.mad-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--mad-text-sm);
}

.mad-table thead { background: var(--mad-bg-subtle); }

.mad-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: var(--mad-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--mad-text-muted);
  border-bottom: 1px solid var(--mad-border);
  white-space: nowrap;
}

.mad-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--mad-border);
  color: var(--mad-text);
  vertical-align: middle;
}

.mad-table tbody tr:last-child td { border-bottom: none; }
.mad-table-hover  tbody tr:hover td { background: var(--mad-bg-subtle); cursor: pointer; }
.mad-table-striped tbody tr:nth-child(even) td { background: var(--mad-bg-subtle); }


/* ═══════════════════════════════════════════════════════════════════
   20. COMPONENTE — SPINNER
   ═══════════════════════════════════════════════════════════════════ */

.mad-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2.5px solid var(--mad-border);
  border-top-color: var(--mad-primary);
  border-radius: 50%;
  animation: mad-spin .65s linear infinite;
  flex-shrink: 0;
}
.mad-spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.mad-spinner-lg { width: 32px; height: 32px; border-width: 3px; }

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

/* Utilidade: aplica a animacao de rotacao em qualquer elemento (ex: icone lucide dentro de botao loading) */
.mad-spin { animation: mad-spin .65s linear infinite; display: inline-block; }

/* ── Transporter ─────────────────────────────────────────────────── */
.mad-transporter { position: relative; }
.mad-transporter-loading {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; color: #9ca3af;
  border: 1px dashed #e5e7eb; border-radius: 8px; padding: 32px;
}
.mad-transporter-loading-text { font-size: 13px; }


/* ═══════════════════════════════════════════════════════════════════
   21. COMPONENTE — SKELETON
   ═══════════════════════════════════════════════════════════════════ */

.mad-skeleton {
  background: linear-gradient(
    90deg,
    var(--mad-bg-muted) 25%,
    var(--mad-border) 50%,
    var(--mad-bg-muted) 75%
  );
  background-size: 200% 100%;
  animation: mad-shimmer 1.5s infinite;
  border-radius: var(--mad-radius-sm);
}

@keyframes mad-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ═══════════════════════════════════════════════════════════════════
   22. COMPONENTE — SEPARATOR
   ═══════════════════════════════════════════════════════════════════ */

.mad-sep   { border: none; background: var(--mad-border); display: block; }
.mad-sep-h { height: 1px; width: 100%; margin: var(--mad-s3) 0; }
.mad-sep-v { width: 1px; height: 100%; margin: 0 var(--mad-s2); align-self: stretch; display: inline-block; }


/* ═══════════════════════════════════════════════════════════════════
   23. COMPONENTE — SECTION TITLE
   ═══════════════════════════════════════════════════════════════════ */

.mad-section       { margin-top: var(--mad-s5); }
.mad-section-first { margin-top: var(--mad-s4); }

.mad-section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-bottom: var(--mad-s2);
  border-bottom: 2px solid var(--mad-border);
  margin-bottom: var(--mad-s4);
  font-size: var(--mad-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--mad-text-muted);
}


/* ═══════════════════════════════════════════════════════════════════
   24. COMPONENTE — SELECT CARD (seletor visual estilo tipo/plano)
   ═══════════════════════════════════════════════════════════════════ */

.mad-select-cards { display: flex; gap: var(--mad-s2); }
.mad-select-cards-col { flex-direction: column; }

.mad-select-card {
  flex: 1;
  cursor: pointer;
  border: 2px solid var(--mad-border);
  border-radius: var(--mad-radius-md);
  padding: 14px 12px;
  background: var(--mad-bg-subtle);
  transition: border-color var(--mad-t), background var(--mad-t);
  user-select: none;
}
.mad-select-card:hover {
  border-color: var(--mad-border-strong);
  background: var(--mad-bg-muted);
}
.mad-select-card-active,
.mad-select-card[aria-selected="true"] {
  border-color: var(--mad-accent);
  background: var(--mad-accent-subtle);
}

.mad-select-card-icon  { font-size: 22px; line-height: 1; margin-bottom: var(--mad-s1); }
.mad-select-card-title { display: block; font-size: var(--mad-text-sm); font-weight: 700; color: var(--mad-text); }
.mad-select-card-active .mad-select-card-title,
.mad-select-card[aria-selected="true"] .mad-select-card-title { color: var(--mad-text); }
.mad-select-card-desc  { display: block; font-size: var(--mad-text-xs); color: var(--mad-text-muted); line-height: 1.4; margin-top: 3px; }


/* ═══════════════════════════════════════════════════════════════════
   25. COMPONENTE — DRAWER LAYOUT
   ═══════════════════════════════════════════════════════════════════ */

.mad-drawer        { display: flex; flex-direction: column; height: 100%; background: var(--mad-bg); }
.mad-drawer-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  padding: var(--mad-s5);
  border-bottom: 1px solid var(--mad-border);
  flex-shrink: 0;
}
.mad-drawer-header-left {
  display: flex; align-items: center; gap: 12px; min-width: 0;
}
.mad-drawer-header-icon-group {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.mad-drawer-header-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--mad-border);
  background: var(--mad-bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--mad-text-subtle);
}
.mad-drawer-header-vdivider {
  width: 1px; height: 32px;
  background: var(--mad-border);
  flex-shrink: 0;
}
.mad-drawer-header-meta { min-width: 0; }
.mad-drawer-body   { flex: 1; overflow-y: auto; padding: var(--mad-s1) var(--mad-s5) var(--mad-s6); }
.mad-drawer-footer {
  padding: var(--mad-s3) var(--mad-s5);
  border-top: 1px solid var(--mad-border);
  flex-shrink: 0;
  background: var(--mad-bg);
}

.mad-drawer-icon {
  width: 36px; height: 36px;
  border-radius: var(--mad-radius);
  background: linear-gradient(135deg, var(--mad-primary), var(--mad-primary-hover));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; flex-shrink: 0;
}
.mad-drawer-title    { font-size: 1.1rem; font-weight: 600; color: var(--mad-text); letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mad-drawer-subtitle { font-size: var(--mad-text-xs); color: var(--mad-text-subtle); }


/* ═══════════════════════════════════════════════════════════════════
   26. COMPONENTE — FORM SECTION (grupo de campos com header)
   ═══════════════════════════════════════════════════════════════════ */

.mad-form-section              { 
  display: flex; flex-direction: column; gap: 16px; padding-bottom: var(--mad-s4); 
  /* border-bottom: 1px solid var(--mad-border);  */
  margin-bottom: var(--mad-s4);
}
.mad-form-section-header       { 
  padding-top: 6px;
  padding-bottom: 6px;
}
.mad-form-section-meta         { display: flex; align-items: center; gap: 12px; }
.mad-form-section-icon         {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--mad-primary) 10%, transparent);
  flex-shrink: 0;
}
.mad-form-section-icon i,
.mad-form-section-icon svg     { width: 20px; height: 20px; color: var(--mad-primary); }
.mad-form-section-text         { display: flex; flex-direction: column; gap: 2px; }
.mad-form-section-title        { font-size: .875rem; font-weight: 600; color: var(--mad-text); }
.mad-form-section-subtitle     { font-size: .75rem; color: var(--mad-text-subtle); }
.mad-form-section-divider      { height: 1px; background: var(--mad-border); margin-top: 10px; }

/* Form actions — footer de botões */
.mad-form-actions              { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.mad-form-actions-right        { justify-content: flex-end; }
.mad-form-actions-center       { justify-content: center; }


/* ═══════════════════════════════════════════════════════════════════
   27. COMPONENTE — INFO BOX (preview / detalhe somente-leitura)
   ═══════════════════════════════════════════════════════════════════ */

.mad-info-box {
  display: flex;
  align-items: center;
  gap: var(--mad-s2);
  background: var(--mad-bg-subtle);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius);
  padding: 10px 14px;
}
.mad-info-box-icon  { color: var(--mad-text-subtle); font-size: 18px; flex-shrink: 0; }
.mad-info-box-label { font-size: 10px; color: var(--mad-text-subtle); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; }
.mad-info-box-value { font-size: var(--mad-text-sm); color: var(--mad-text); font-weight: 600; }


/* ═══════════════════════════════════════════════════════════════════
   27. COMPONENTE — STAT CARD
   ═══════════════════════════════════════════════════════════════════ */

.mad-stat {
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-lg);
  padding: var(--mad-s4) var(--mad-s5);
  box-shadow: var(--mad-shadow-sm);
}
.mad-stat-label  { font-size: var(--mad-text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--mad-text-muted); }
.mad-stat-value  { font-size: var(--mad-text-3xl); font-weight: 700; color: var(--mad-text); line-height: 1.1; margin-top: 4px; }
.mad-stat-change { font-size: var(--mad-text-xs); margin-top: 4px; }
.mad-stat-change-up   { color: var(--mad-success); }
.mad-stat-change-down { color: var(--mad-danger); }


/* ═══════════════════════════════════════════════════════════════════
   28. COMPONENTE — DISPLAY FIELD (visualização somente-leitura)
   ═══════════════════════════════════════════════════════════════════ */

.mad-display-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
}

.mad-display-field-header {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mad-display-field-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--mad-text-subtle);
  line-height: 1.3;
}

.mad-display-field-icon { width: 13px; height: 13px; color: var(--mad-text-subtle); flex-shrink: 0; }

.mad-display-field-value {
  font-size: var(--mad-text-base);
  font-weight: 500;
  color: var(--mad-text);
  line-height: 1.5;
  word-break: break-word;
}

.mad-display-field-value a      { color: var(--mad-info); text-decoration: none; }
.mad-display-field-value a:hover { text-decoration: underline; }

/* Empty state */
.mad-display-field-empty { color: var(--mad-text-subtle); font-weight: 400; font-style: italic; }

/* Variants */
.mad-display-field-success { color: var(--mad-success); }
.mad-display-field-danger  { color: var(--mad-danger); }
.mad-display-field-warning { color: var(--mad-warning); }
.mad-display-field-info    { color: var(--mad-info); }
.mad-display-field-primary { color: var(--mad-primary); font-weight: 700; }

/* Copy button — aparece no hover */
.mad-display-field-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: var(--mad-radius-sm);
  background: transparent;
  color: var(--mad-text-subtle);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--mad-t), background var(--mad-t), color var(--mad-t);
  margin-left: auto;
  flex-shrink: 0;
}
.mad-display-field:hover .mad-display-field-copy { opacity: 1; }
.mad-display-field-copy:hover { background: var(--mad-bg-muted); color: var(--mad-text); }
.mad-display-field-copied { opacity: 1 !important; color: var(--mad-success) !important; }

/* Expandable — clamp */
.mad-display-field-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mad-display-field-toggle {
  display: inline;
  padding: 0;
  border: none;
  background: none;
  font-size: var(--mad-text-xs);
  color: var(--mad-info);
  cursor: pointer;
  font-weight: 500;
  margin-top: 2px;
}
.mad-display-field-toggle:hover { text-decoration: underline; }

/* Hint */
.mad-display-field-hint {
  font-size: var(--mad-text-xs);
  color: var(--mad-text-subtle);
  line-height: 1.4;
}


/* ═══════════════════════════════════════════════════════════════════
   29. COMPONENTE — EMPTY STATE
   ═══════════════════════════════════════════════════════════════════ */

.mad-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--mad-s10) var(--mad-s6);
  color: var(--mad-text-muted);
  gap: var(--mad-s3);
}
.mad-empty-icon  { font-size: 40px; opacity: .4; }
.mad-empty-title { font-size: var(--mad-text-base); font-weight: 700; color: var(--mad-text); }
.mad-empty-desc  { font-size: var(--mad-text-sm); max-width: 320px; line-height: 1.6; }


/* ═══════════════════════════════════════════════════════════════════
   29. COMPONENTE — NAVBAR (top header — estilo Notch)
   ═══════════════════════════════════════════════════════════════════ */

/* Container */
.mad-navbar {
  position: relative;
  background: #fbfbfb;
  border-bottom: 1px solid var(--mad-border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0;
}

/* Logo slot (esquerda) */
.mad-navbar-logo {
  width: 272px;
  min-width: 272px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0 12px;
  flex-shrink: 0;
}
.mad-navbar-logo img {
  max-height: 36px;
  width: auto;
  object-fit: contain;
}

/* Centro: slot para pills */
.mad-navbar-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 10;
}

/* Direita */
.mad-navbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding-right: 12px;
  flex-shrink: 0;
}

/* ── Pills ── */
/* Pill externa (cinza) */
.mad-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  background: var(--mad-bg-muted);
  border-radius: var(--mad-radius-full);
  padding: 3px 6px;
  box-shadow: var(--mad-shadow-sm), 0 0 0 1px rgba(0,0,0,.06);
}

/* Pill dark (ações principais) */
.mad-pill-dark {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  background: var(--mad-text);
  border-radius: var(--mad-radius-full);
  padding: 2px 6px;
}

/* Pill white (notificações, ações secundárias) */
.mad-pill-white {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  background: var(--mad-bg);
  border-radius: var(--mad-radius-full);
  padding: 2px 6px;
  box-shadow: var(--mad-shadow-sm), 0 0 0 1px rgba(0,0,0,.05);
}

/* Texto de data/info dentro da pill */
.mad-pill-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--mad-text-muted);
  padding: 0 6px;
  white-space: nowrap;
  line-height: 1;
}

/* Botão ícone dentro de pill dark */
.mad-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--mad-radius-full);
  color: rgba(255,255,255,.7);
  font-size: 11px;
  text-decoration: none;
  transition: background var(--mad-t), color var(--mad-t);
  flex-shrink: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}
.mad-pill-btn:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

/* Botão ícone dentro de pill white */
.mad-pill-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--mad-radius-full);
  color: var(--mad-text-muted);
  font-size: 12px;
  text-decoration: none;
  transition: color var(--mad-t), background var(--mad-t);
  flex-shrink: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}
.mad-pill-icon-btn:hover {
  background: var(--mad-bg-muted);
  color: var(--mad-text);
}

/* Botão ícone fora de pill (direita do header) */
.mad-navbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--mad-radius-full);
  color: var(--mad-text-muted);
  font-size: 14px;
  text-decoration: none;
  transition: background var(--mad-t), color var(--mad-t);
  flex-shrink: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}
.mad-navbar-icon-btn:hover {
  background: rgba(0,0,0,.05);
  color: var(--mad-text);
}

/* Botão de usuário (pill com avatar + nome) */
.mad-navbar-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  background: var(--mad-bg);
  border-radius: var(--mad-radius-full);
  padding: 3px 10px 3px 3px;
  box-shadow: var(--mad-shadow-sm), 0 0 0 1px rgba(0,0,0,.05);
  cursor: pointer;
  text-decoration: none;
  transition: box-shadow var(--mad-t);
  border: none;
}
.mad-navbar-user-btn:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,.1), 0 0 0 1px rgba(0,0,0,.08);
}
.mad-navbar-user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--mad-bg-muted);
}
.mad-navbar-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mad-navbar-user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--mad-text);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
}


/* ═══════════════════════════════════════════════════════════════════
   30. COMPONENTE — NAV RAIL (sidebar de ícones — estilo Notch)
   ═══════════════════════════════════════════════════════════════════ */

/* Container externo */
.mad-rail {
  width: 84px;
  min-width: 84px;
  background: var(--mad-bg);
  padding: 12px 0 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow: visible;
}

/* Pill wrapper */
.mad-rail-pill {
  width: 67px;
  background: var(--mad-bg-muted);
  border-radius: 28px;
  padding: 5px 3px 3px;
  box-shadow: var(--mad-shadow-sm), 0 0 0 1px rgba(0,0,0,.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  align-self: flex-start;
}

/* Seção dark (módulos principais) */
.mad-rail-modules {
  background: var(--mad-text);
  border-radius: 22px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  margin-bottom: 3px;
  overflow: hidden;
}

/* Item dentro da seção dark */
.mad-rail-item {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--mad-t), color var(--mad-t);
  border: none;
  flex-shrink: 0;
}

/* Item no rail dark */
.mad-rail-modules .mad-rail-item {
  background: transparent;
  color: rgba(255,255,255,.7);
}
.mad-rail-modules .mad-rail-item:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.mad-rail-modules .mad-rail-item.mad-active {
  background: #fff;
  color: var(--mad-text);
  box-shadow: var(--mad-shadow-sm), 0 0 0 1px rgba(0,0,0,.06);
}

/* Seção light (abaixo do dark) */
.mad-rail-light {
  padding: 4px 0 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}

/* Item no rail light */
.mad-rail-light .mad-rail-item {
  background: transparent;
  color: var(--mad-text-muted);
}
.mad-rail-light .mad-rail-item:hover {
  background: rgba(0,0,0,.05);
  color: var(--mad-text);
}
.mad-rail-light .mad-rail-item.mad-active {
  background: var(--mad-bg);
  color: var(--mad-text);
  box-shadow: var(--mad-shadow-sm), 0 0 0 1px rgba(0,0,0,.05);
}


/* ═══════════════════════════════════════════════════════════════════
   31. COMPONENTE — SUBMENU (painel lateral de itens)
   ═══════════════════════════════════════════════════════════════════ */

.mad-submenu {
  width: 272px;
  min-width: 272px;
  background: var(--mad-bg);
  border-right: 1px solid var(--mad-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Título do módulo */
.mad-submenu-title {
  font-size: var(--mad-text-base);
  font-weight: 600;
  color: var(--mad-text);
  padding: 14px 20px 8px;
  flex-shrink: 0;
}

/* Lista de itens */
.mad-submenu-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
  scrollbar-width: none;
}
.mad-submenu-list::-webkit-scrollbar { display: none; }

/* Item do menu */
.mad-submenu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--mad-radius-xl);
  padding: 8px;
  font-size: var(--mad-text-sm);
  color: var(--mad-text-muted);
  text-decoration: none;
  transition: background var(--mad-t), color var(--mad-t), border-color var(--mad-t);
  line-height: 1.4;
  margin-bottom: 2px;
  border-left: 2px solid transparent;
  cursor: pointer;
  border-radius: var(--mad-radius-xl);
}
.mad-submenu-item i {
  color: var(--mad-text-subtle);
  font-size: 14px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}
.mad-submenu-item:hover {
  background: var(--mad-accent-subtle);
  color: var(--mad-text);
  border-left-color: var(--mad-accent-border);
}
.mad-submenu-item:hover i { color: var(--mad-text-muted); }

/* Item ativo */
.mad-submenu-item.mad-active {
  background: var(--mad-accent-subtle);
  color: var(--mad-accent);
  border-left-color: var(--mad-accent);
}
.mad-submenu-item.mad-active i { color: var(--mad-accent); }

/* Sub-nível (nível 3) */
.mad-submenu-children {
  margin: 2px 8px 2px 12px;
  padding: 2px 0 2px 10px;
  border-left: 1.5px solid var(--mad-border);
}
.mad-submenu-children .mad-submenu-item {
  border-radius: var(--mad-radius);
  padding: 6px;
  font-size: 12.5px;
  color: var(--mad-text-subtle);
  border-left: none;
}
.mad-submenu-children .mad-submenu-item i { display: none; }
.mad-submenu-children .mad-submenu-item:hover {
  background: transparent;
  color: var(--mad-text);
  border-left: none;
}
.mad-submenu-children .mad-submenu-item.mad-active {
  background: transparent;
  color: var(--mad-accent);
  font-weight: 600;
  border-left: none;
}

/* Separador de seção dentro do submenu */
.mad-submenu-sep {
  font-size: 11px;
  color: var(--mad-text-subtle);
  padding: 4px 8px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Rodapé do submenu (menu-tools) */
.mad-submenu-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--mad-border);
  flex-shrink: 0;
}
.mad-submenu-footer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--mad-text-subtle);
  padding: 6px 8px;
  border-radius: 10px;
  text-decoration: none;
  margin-top: 2px;
  transition: background var(--mad-t), color var(--mad-t);
}
.mad-submenu-footer-item:hover {
  background: var(--mad-bg-muted);
  color: var(--mad-text-muted);
}
.mad-submenu-footer-unit {
  background: var(--mad-bg-muted);
  border-radius: var(--mad-radius);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--mad-text-muted);
}
.mad-submenu-footer-version {
  font-size: 11px;
  color: var(--mad-border-strong);
  text-align: center;
  padding: 6px 0 0;
}


/* ═══════════════════════════════════════════════════════════════════
   32. COMPONENTE — MEGAMENU (apps dropdown grid)
   ═══════════════════════════════════════════════════════════════════ */

.mad-megamenu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 560px;
  background: var(--mad-bg);
  border-radius: var(--mad-radius-xl);
  border: 1px solid rgba(0,0,0,.05);
  box-shadow: var(--mad-shadow-xl);
  padding: 20px;
  z-index: 9999;
}

/* Busca no topo */
.mad-megamenu-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--mad-bg-muted);
  border-radius: var(--mad-radius);
  padding: 5px 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--mad-bg-muted);
}
.mad-megamenu-search-icon { font-size: 13px; color: var(--mad-text-subtle); flex-shrink: 0; }
.mad-megamenu-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  color: var(--mad-text);
  padding: 0;
  line-height: 1;
}
.mad-megamenu-search-input::placeholder { color: var(--mad-text-subtle); }

/* Grid 2 colunas */
.mad-megamenu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Coluna de módulo */
.mad-megamenu-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Header do módulo */
.mad-megamenu-module-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.mad-megamenu-module-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--mad-radius);
  background: var(--mad-text);
  color: #fff;
  font-size: 11px;
  flex-shrink: 0;
}
.mad-megamenu-module-icon i,
.mad-megamenu-module-icon svg { font-size: 11px; color: #fff; }
.mad-megamenu-module-title {
  font-size: var(--mad-text-sm);
  font-weight: 600;
  color: var(--mad-text);
  line-height: 1;
}

/* Lista de itens */
.mad-megamenu-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Item individual */
.mad-megamenu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--mad-radius);
  padding: 7px 10px;
  font-size: var(--mad-text-sm);
  color: var(--mad-text-muted);
  text-decoration: none;
  transition: background var(--mad-t), color var(--mad-t);
  cursor: pointer;
}
.mad-megamenu-item:hover {
  background: var(--mad-bg-muted);
  color: var(--mad-text);
}
.mad-megamenu-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  flex-shrink: 0;
}
.mad-megamenu-item-icon i { font-size: 13px; color: var(--mad-text-subtle); }
.mad-megamenu-item:hover .mad-megamenu-item-icon i { color: var(--mad-text-muted); }
.mad-megamenu-item span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ═══════════════════════════════════════════════════════════════════
   31. COMPONENTE — FIELD helpers (aliases)
   ═══════════════════════════════════════════════════════════════════ */

.mad-field-hint { font-size: var(--mad-text-xs); color: var(--mad-text-subtle); line-height: 1.5; }
[data-field-error]:empty { display: none; }
.mad-required   { color: var(--mad-danger); margin-left: 2px; }


/* ═══════════════════════════════════════════════════════════════════
   32. COMPONENTE — PROGRESS
   ═══════════════════════════════════════════════════════════════════ */

.mad-progress {
  width: 100%;
  height: 8px;
  background: var(--mad-bg-muted);
  border-radius: var(--mad-radius-full);
  overflow: hidden;
}
.mad-progress-bar {
  height: 100%;
  background: var(--mad-primary);
  border-radius: var(--mad-radius-full);
  transition: width .35s ease;
  min-width: 0;
}
.mad-progress-sm { height: 4px; }
.mad-progress-lg { height: 12px; }
.mad-progress-success .mad-progress-bar { background: var(--mad-success); }
.mad-progress-warning .mad-progress-bar { background: var(--mad-warning); }
.mad-progress-danger  .mad-progress-bar { background: var(--mad-danger); }
.mad-progress-info    .mad-progress-bar { background: var(--mad-info); }


/* ═══════════════════════════════════════════════════════════════════
   33. COMPONENTE — CALLOUT
   ═══════════════════════════════════════════════════════════════════ */

.mad-callout {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-md);
  background: var(--mad-bg-subtle);
  font-size: var(--mad-text-sm);
}
.mad-callout-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--mad-text);
  line-height: 1.3;
}
.mad-callout-body  { color: var(--mad-text-muted); line-height: 1.6; margin-left: 24px; }
.mad-callout-footer { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; margin-left: 24px; }

.mad-callout-info    { border-color: rgba(74,144,217,.35);  background: var(--mad-info-subtle);    color: #1a3a5c; }
.mad-callout-success { border-color: rgba(22,163,74,.35);   background: var(--mad-success-subtle); color: #14532d; }
.mad-callout-warning { border-color: rgba(217,119,6,.35);   background: var(--mad-warning-subtle); color: #78350f; }
.mad-callout-danger  { border-color: rgba(220,38,38,.35);   background: var(--mad-danger-subtle);  color: #7f1d1d; }


/* ── Code block (documentação) ────────────────────────────────────── */
.mad-code {
  background: #1e1e2e;
  color: #cdd6f4;
  border-radius: var(--mad-radius-md);
  padding: 16px 20px;
  margin-top: 12px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
}
.mad-code code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  white-space: pre;
}

/* ═══════════════════════════════════════════════════════════════════
   34. COMPONENTE — ACCORDION
   ═══════════════════════════════════════════════════════════════════ */

.mad-accordion {
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-lg);
  overflow: hidden;
}
.mad-accordion-item + .mad-accordion-item {
  border-top: 1px solid var(--mad-border);
}
.mad-accordion-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  font-size: var(--mad-text-sm);
  font-weight: 600;
  color: var(--mad-text);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  gap: 12px;
  transition: background var(--mad-t);
}
.mad-accordion-trigger:hover { background: var(--mad-bg-subtle); }
.mad-accordion-body {
  padding: 0 16px 16px;
  font-size: var(--mad-text-sm);
  color: var(--mad-text-muted);
  line-height: 1.6;
}


/* ═══════════════════════════════════════════════════════════════════
   35. COMPONENTE — DROPDOWN
   ═══════════════════════════════════════════════════════════════════ */

.mad-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-md);
  box-shadow: var(--mad-shadow-md);
  z-index: 100;
  padding: 4px;
}
.mad-dropdown-end { left: auto; right: 0; }

.mad-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--mad-radius-sm);
  font-size: var(--mad-text-sm);
  color: var(--mad-text);
  cursor: pointer;
  user-select: none;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  text-decoration: none;
  transition: background var(--mad-t);
}
.mad-dropdown-item:hover { background: var(--mad-bg-muted); }
.mad-dropdown-item:disabled,
.mad-dropdown-item[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }

.mad-dropdown-item-danger       { color: var(--mad-danger); }
.mad-dropdown-item-danger:hover { background: var(--mad-danger-subtle); }

.mad-dropdown-sep { height: 1px; background: var(--mad-border); margin: 4px 0; }

.mad-dropdown-label {
  padding: 5px 10px 3px;
  font-size: var(--mad-text-xs);
  font-weight: 700;
  color: var(--mad-text-subtle);
  text-transform: uppercase;
  letter-spacing: .5px;
}


/* ═══════════════════════════════════════════════════════════════════
   36. COMPONENTE — MODAL
   ═══════════════════════════════════════════════════════════════════ */

.mad-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 1010;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.mad-modal {
  background: var(--mad-bg);
  border-radius: var(--mad-radius-lg);
  box-shadow: var(--mad-shadow-xl);
  width: 100%;
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mad-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--mad-border);
  flex-shrink: 0;
  gap: 12px;
}
.mad-modal-title { font-size: var(--mad-text-base); font-weight: 700; color: var(--mad-text); line-height: 1.3; flex: 1; }
.mad-modal-body  { padding: 20px; overflow-y: auto; flex: 1; }
.mad-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--mad-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: var(--mad-bg-subtle);
  flex-shrink: 0;
  flex-wrap: wrap;
}


/* ═══════════════════════════════════════════════════════════════════
   37. COMPONENTE — TOOLTIP
   ═══════════════════════════════════════════════════════════════════ */

.mad-tooltip-wrap { position: relative; display: inline-flex; }

.mad-tooltip {
  position: absolute;
  background: var(--mad-tooltip-bg);
  color: var(--mad-tooltip-fg);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--mad-radius-sm);
  white-space: nowrap;
  pointer-events: none;
  z-index: 150;
  line-height: 1.4;
  box-shadow: var(--mad-shadow-md);
}

/* top (padrão) */
.mad-tooltip-top {
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
}
.mad-tooltip-top::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--mad-tooltip-bg);
}

/* bottom */
.mad-tooltip-bottom {
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
}
.mad-tooltip-bottom::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-bottom-color: var(--mad-tooltip-bg);
}

/* left */
.mad-tooltip-left {
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
}
.mad-tooltip-left::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-left-color: var(--mad-tooltip-bg);
}

/* right */
.mad-tooltip-right {
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
}
.mad-tooltip-right::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 100%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-right-color: var(--mad-tooltip-bg);
}

/* Variante flutuante — tooltip global posicionado via JS (ver mad-ui.js).
   Substitui o Bootstrap tooltip do Adianti para elementos com [title]. */
.mad-tooltip-floating {
  position: fixed;
  top: auto; right: auto; bottom: auto; left: auto;
  transform: none;
  max-width: 360px;
  white-space: normal;
  word-wrap: break-word;
  /* Acima de drawer/modal/toast (max int32 - 1 para ficar sempre no topo). */
  z-index: 2147483646;
}


/* ═══════════════════════════════════════════════════════════════════
   38. COMPONENTE — TOAST
   ═══════════════════════════════════════════════════════════════════ */

/* ── Sonner-style toast system ── */

/* Toaster container */
.mad-toast-region {
  position: fixed;
  width: 356px;
  z-index: 999999999;
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  list-style: none;
  outline: none;
  --border-radius: 8px;
}

/* Container Y position */
.mad-toast-region[data-y-position="bottom"] { bottom: 24px; }
.mad-toast-region[data-y-position="top"]    { top: 24px; }

/* Container X position */
.mad-toast-region[data-x-position="right"]  { right: 24px; }
.mad-toast-region[data-x-position="left"]   { left: 24px; }
.mad-toast-region[data-x-position="center"] { left: 50%; transform: translateX(-50%); }

/* Individual toast */
.mad-toast {
  --y: translateY(100%);
  --lift-amount: calc(var(--lift) * var(--gap));
  z-index: var(--z-index);
  position: absolute;
  opacity: 0;
  transform: var(--y);
  touch-action: none;
  transition: transform 400ms, opacity 400ms, height 400ms, box-shadow 200ms;
  box-sizing: border-box;
  outline: none;
  overflow-wrap: anywhere;
}

.mad-toast[data-styled="true"] {
  padding: 16px;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  color: var(--mad-text);
  border-radius: var(--border-radius);
  box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
  width: 356px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Toast Y position — bottom (default) */
.mad-toast[data-y-position="bottom"] {
  bottom: 0;
  --y: translateY(100%);
  --lift: -1;
  --lift-amount: calc(var(--lift) * var(--gap));
}

/* Toast Y position — top */
.mad-toast[data-y-position="top"] {
  top: 0;
  --y: translateY(-100%);
  --lift: 1;
  --lift-amount: calc(1 * var(--gap));
}

/* Toast X position */
.mad-toast[data-x-position="right"] { right: 0; }
.mad-toast[data-x-position="left"]  { left: 0; }

/* Mounted = slide in */
.mad-toast[data-mounted="true"] {
  --y: translateY(0);
  opacity: 1;
}

/* Stacked (not expanded, behind front) — Sonner formula */
.mad-toast[data-expanded="false"][data-front="false"] {
  --scale: var(--toasts-before) * 0.05 + 1;
  --y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));
  height: var(--front-toast-height);
}

/* Children transitions */
.mad-toast > * {
  transition: opacity 400ms;
}

/* Stacked: hide content behind front toast */
.mad-toast[data-expanded="false"][data-front="false"][data-styled="true"] > * {
  opacity: 0;
}

/* Hidden beyond visible limit */
.mad-toast[data-visible="false"] {
  opacity: 0;
  pointer-events: none;
}

/* Expanded (hover) */
.mad-toast[data-mounted="true"][data-expanded="true"] {
  --y: translateY(calc(var(--lift) * var(--offset)));
  height: var(--initial-height);
}

/* Expanded gap filler (keeps hover continuous between toasts) */
.mad-toast[data-expanded="true"]::after {
  content: '';
  position: absolute;
  left: 0;
  height: calc(var(--gap) + 1px);
  bottom: 100%;
  width: 100%;
}

/* ── Removed states ── */
.mad-toast[data-removed="true"][data-front="true"][data-swipe-out="false"] {
  --y: translateY(calc(var(--lift) * -100%));
  opacity: 0;
}
.mad-toast[data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"] {
  --y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));
  opacity: 0;
}
.mad-toast[data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"] {
  --y: translateY(40%);
  opacity: 0;
  transition: transform 500ms, opacity 200ms;
}

/* ── Swiping ── */
.mad-toast[data-swiping="true"] {
  transform: var(--y) translateY(var(--swipe-amount-y, 0px)) translateX(var(--swipe-amount-x, 0px));
  transition: none;
}

/* Swipe out animations */
.mad-toast[data-swipe-out="true"] {
  animation-duration: 200ms;
  animation-timing-function: ease-out;
  animation-fill-mode: forwards;
}
.mad-toast[data-swipe-out="true"][data-swipe-direction="left"]  { animation-name: mad-swipe-out-left; }
.mad-toast[data-swipe-out="true"][data-swipe-direction="right"] { animation-name: mad-swipe-out-right; }
.mad-toast[data-swipe-out="true"][data-swipe-direction="down"]  { animation-name: mad-swipe-out-down; }
.mad-toast[data-swipe-out="true"][data-swipe-direction="up"]    { animation-name: mad-swipe-out-up; }

@keyframes mad-swipe-out-left {
  from { transform: var(--y) translateX(var(--swipe-amount-x)); opacity: 1; }
  to   { transform: var(--y) translateX(calc(var(--swipe-amount-x) - 100%)); opacity: 0; }
}
@keyframes mad-swipe-out-right {
  from { transform: var(--y) translateX(var(--swipe-amount-x)); opacity: 1; }
  to   { transform: var(--y) translateX(calc(var(--swipe-amount-x) + 100%)); opacity: 0; }
}
@keyframes mad-swipe-out-down {
  from { transform: var(--y) translateY(var(--swipe-amount-y)); opacity: 1; }
  to   { transform: var(--y) translateY(calc(var(--swipe-amount-y) + 100%)); opacity: 0; }
}
@keyframes mad-swipe-out-up {
  from { transform: var(--y) translateY(var(--swipe-amount-y)); opacity: 1; }
  to   { transform: var(--y) translateY(calc(var(--swipe-amount-y) - 100%)); opacity: 0; }
}

/* ── Rich colors ── */
[data-rich-colors="true"][data-type="success"] {
  background: hsl(143, 85%, 96%);
  border-color: hsl(145, 92%, 87%);
  color: hsl(140, 100%, 27%);
}
[data-rich-colors="true"][data-type="danger"] {
  background: hsl(359, 100%, 97%);
  border-color: hsl(359, 100%, 94%);
  color: hsl(360, 100%, 45%);
}
[data-rich-colors="true"][data-type="warning"] {
  background: hsl(49, 100%, 97%);
  border-color: hsl(49, 91%, 84%);
  color: hsl(31, 92%, 45%);
}
[data-rich-colors="true"][data-type="info"] {
  background: hsl(208, 100%, 97%);
  border-color: hsl(221, 91%, 93%);
  color: hsl(210, 92%, 45%);
}

/* Rich colors — close button inherits */
[data-rich-colors="true"] .mad-toast-close {
  background: inherit;
  border-color: inherit;
  color: inherit;
}

/* ── Icon ── */
.mad-toast-icon {
  display: flex;
  height: 16px;
  width: 16px;
  position: relative;
  justify-content: flex-start;
  align-items: center;
  flex-shrink: 0;
  margin-left: -3px;
  margin-right: 4px;
}

/* ── Content ── */
.mad-toast-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.mad-toast-title {
  font-weight: 500;
  line-height: 1.5;
  color: inherit;
}
.mad-toast-desc {
  font-weight: 400;
  line-height: 1.4;
  color: inherit;
  opacity: 0.7;
}
[data-rich-colors="true"] .mad-toast-desc {
  color: inherit;
  opacity: 0.85;
}

/* ── Close button ── */
.mad-toast-close {
  position: absolute;
  left: 0;
  top: 0;
  height: 20px;
  width: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  color: var(--mad-text-subtle);
  transform: translate(-35%, -35%);
  border-radius: 50%;
  cursor: pointer;
  z-index: 1;
  opacity: 0;
  transition: opacity 100ms, background 200ms, border-color 200ms;
}
.mad-toast:hover .mad-toast-close { opacity: 1; }
.mad-toast-close:hover { background: var(--mad-bg-hover, #f5f5f5); }

/* ── Reduced motion ── */
@media (prefers-reduced-motion) {
  .mad-toast, .mad-toast > * {
    transition: none !important;
    animation: none !important;
  }
}

/* ── Mobile ── */
@media (max-width: 600px) {
  .mad-toast-region {
    right: 16px;
    left: 16px;
    bottom: 16px;
    width: 100%;
  }
  .mad-toast {
    left: 0;
    right: 0;
    width: calc(100% - 32px);
  }
}


/* ═══════════════════════════════════════════════════════════════════
   39. COMPONENTE — PAGINATION
   ═══════════════════════════════════════════════════════════════════ */

.mad-pagination { display: flex; align-items: center; gap: 4px; }

.mad-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius);
  font-size: var(--mad-text-sm);
  color: var(--mad-text);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--mad-t), border-color var(--mad-t), color var(--mad-t);
  user-select: none;
  white-space: nowrap;
}
.mad-page-btn:hover { background: var(--mad-bg-subtle); }
.mad-page-btn-active {
  background: var(--mad-primary);
  color: var(--mad-primary-fg);
  border-color: var(--mad-primary);
}
.mad-page-btn-active:hover { opacity: .88; background: var(--mad-primary); }
.mad-page-btn:disabled,
.mad-page-btn[disabled] { opacity: .4; cursor: not-allowed; pointer-events: none; }
.mad-page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  color: var(--mad-text-subtle);
  font-size: var(--mad-text-sm);
}


/* ═══════════════════════════════════════════════════════════════════
   40. COMPONENTE — BTN GROUP
   ═══════════════════════════════════════════════════════════════════ */

.mad-btn-group {
  display: inline-flex;
}
.mad-btn-group .mad-btn {
  border-radius: 0;
  margin-left: -1px;
}
.mad-btn-group .mad-btn:first-child { border-radius: var(--mad-radius) 0 0 var(--mad-radius); margin-left: 0; }
.mad-btn-group .mad-btn:last-child  { border-radius: 0 var(--mad-radius) var(--mad-radius) 0; }
.mad-btn-group .mad-btn:only-child  { border-radius: var(--mad-radius); margin-left: 0; }
.mad-btn-group .mad-btn:hover,
.mad-btn-group .mad-btn:focus { z-index: 1; }


/* ═══════════════════════════════════════════════════════════════════
   41. COMPONENTE — CHECKBOX
   ═══════════════════════════════════════════════════════════════════ */

.mad-checkbox-wrap {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.mad-checkbox-wrap:has(input:disabled) { opacity: .5; cursor: not-allowed; }

input[type="checkbox"].mad-checkbox { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; border: 0; padding: 0; appearance: none; -webkit-appearance: none; }
input[type="checkbox"].mad-checkbox::before { display: none; content: none; }

.mad-checkbox-box {
  width: 16px;
  height: 16px;
  min-width: 16px;
  border: 2px solid var(--mad-border-strong);
  border-radius: var(--mad-radius-sm);
  background: var(--mad-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: border-color var(--mad-t), background var(--mad-t);
  position: relative;
}
.mad-checkbox:checked ~ .mad-checkbox-box {
  background: var(--mad-primary);
  border-color: var(--mad-primary);
}
.mad-checkbox:checked ~ .mad-checkbox-box::after {
  content: '';
  display: block;
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}
.mad-checkbox:focus-visible ~ .mad-checkbox-box {
  outline: 2px solid var(--mad-primary);
  outline-offset: 2px;
}
.mad-checkbox-label { font-size: var(--mad-text-sm); color: var(--mad-text); line-height: 1.4; }


/* ═══════════════════════════════════════════════════════════════════
   42. COMPONENTE — RADIO
   ═══════════════════════════════════════════════════════════════════ */

.mad-radio-wrap {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.mad-radio-wrap:has(input:disabled) { opacity: .5; cursor: not-allowed; }

.mad-radio { position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; pointer-events: none; }

.mad-radio-circle {
  width: 16px;
  height: 16px;
  min-width: 16px;
  border: 2px solid var(--mad-border-strong);
  border-radius: 50%;
  background: var(--mad-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: border-color var(--mad-t), background var(--mad-t);
}
.mad-radio:checked ~ .mad-radio-circle { border-color: var(--mad-primary); }
.mad-radio:checked ~ .mad-radio-circle::after {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--mad-primary);
  border-radius: 50%;
  display: block;
}
.mad-radio:focus-visible ~ .mad-radio-circle {
  outline: 2px solid var(--mad-primary);
  outline-offset: 2px;
}
.mad-radio-label { font-size: var(--mad-text-sm); color: var(--mad-text); line-height: 1.4; }

/* Tamanhos */
.mad-radio-group-sm .mad-radio-circle { width: 14px; height: 14px; min-width: 14px; }
.mad-radio-group-sm .mad-radio:checked ~ .mad-radio-circle::after { width: 6px; height: 6px; }
.mad-radio-group-sm .mad-radio-label { font-size: var(--mad-text-xs, 12px); }
.mad-radio-group-lg .mad-radio-circle { width: 20px; height: 20px; min-width: 20px; }
.mad-radio-group-lg .mad-radio:checked ~ .mad-radio-circle::after { width: 9px; height: 9px; }
.mad-radio-group-lg .mad-radio-label { font-size: var(--mad-text-md, 15px); }

/* Variante button (segmented btn-group) */
.mad-radio-btn-group {
  display: inline-flex;
  flex-direction: row;
  border: 1px solid var(--mad-border-strong);
  border-radius: var(--mad-radius);
  overflow: hidden;
  background: var(--mad-bg);
}
.mad-radio-btn-group.mad-radio-btn-stack {
  flex-direction: column;
  display: flex;
  width: max-content;
}
.mad-radio-btn-group.mad-radio-btn-stack .mad-radio-btn + .mad-radio-btn { border-top: 1px solid var(--mad-border); border-left: 0; }
.mad-radio-btn-input { position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; pointer-events: none; }
.mad-radio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  font-size: var(--mad-text-sm);
  color: var(--mad-text-muted, var(--mad-text));
  background: transparent;
  cursor: pointer;
  user-select: none;
  transition: background var(--mad-t), color var(--mad-t), box-shadow var(--mad-t);
  position: relative;
  white-space: nowrap;
  line-height: 1.2;
}
.mad-radio-btn + .mad-radio-btn { border-left: 1px solid var(--mad-border); }
.mad-radio-btn:hover:not(.is-active):not(.is-disabled) { background: var(--mad-bg-soft, rgba(0,0,0,0.03)); color: var(--mad-text); }
.mad-radio-btn.is-active {
  background: var(--mad-primary);
  color: #fff;
  box-shadow: inset 0 0 0 1px var(--mad-primary);
}
.mad-radio-btn.is-disabled { opacity: .5; cursor: not-allowed; }
.mad-radio-btn-input:focus-visible + .mad-radio-btn-label,
.mad-radio-btn:focus-within { outline: 2px solid var(--mad-primary); outline-offset: 1px; }
.mad-radio-group-sm .mad-radio-btn,
.mad-radio-btn-group.mad-radio-group-sm .mad-radio-btn { padding: 5px 10px; font-size: var(--mad-text-xs, 12px); }
.mad-radio-group-lg .mad-radio-btn,
.mad-radio-btn-group.mad-radio-group-lg .mad-radio-btn { padding: 11px 18px; font-size: var(--mad-text-md, 15px); }


/* ═══════════════════════════════════════════════════════════════════
   43. COMPONENTE — INPUT GROUP (prefix / suffix)
   ═══════════════════════════════════════════════════════════════════ */

.mad-input-group {
  display: flex;
  align-items: stretch;
}
.mad-input-group .mad-input {
  flex: 1;
  min-width: 0;
  border-radius: 0;
}
.mad-input-addon {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  font-size: var(--mad-text-sm);
  font-weight: 600;
  color: var(--mad-text-muted);
  background: var(--mad-bg-muted);
  border: 1.5px solid var(--mad-border);
  white-space: nowrap;
  line-height: 1;
}
.mad-input-group .mad-input-addon:first-child {
  border-right: none;
  border-radius: var(--mad-radius) 0 0 var(--mad-radius);
}
.mad-input-group .mad-input:first-child {
  border-radius: var(--mad-radius) 0 0 var(--mad-radius);
}
.mad-input-group .mad-input:last-child {
  border-radius: 0 var(--mad-radius) var(--mad-radius) 0;
}
.mad-input-addon-r {
  border-left: none;
  border-radius: 0 var(--mad-radius) var(--mad-radius) 0;
}

/* Botão calendário do date-field */
.mad-datepicker-btn {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  background: var(--mad-bg-muted);
  border: 1.5px solid var(--mad-border);
  border-left: none;
  border-radius: 0 var(--mad-radius) var(--mad-radius) 0;
  color: var(--mad-text-muted);
  cursor: pointer;
  line-height: 1;
  transition: background var(--mad-transition), color var(--mad-transition);
}
.mad-datepicker-btn:hover:not(:disabled) {
  background: var(--mad-bg-subtle);
  color: var(--mad-primary);
}
.mad-datepicker-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* password-field — botão eye/eye-off (toggle de visibilidade) */
.mad-password-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  background: var(--mad-bg-muted);
  border: 1.5px solid var(--mad-border);
  border-left: none;
  border-radius: 0 var(--mad-radius) var(--mad-radius) 0;
  color: var(--mad-text-muted);
  cursor: pointer;
  line-height: 1;
  transition: background var(--mad-transition), color var(--mad-transition);
}
.mad-password-toggle-btn:hover:not(:disabled) {
  background: var(--mad-bg-subtle);
  color: var(--mad-primary);
}
.mad-password-toggle-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* password-field — popover com regras de senha forte */
.mad-password-strength-popover {
  position: absolute;
  z-index: 50;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 6px;
  background: var(--mad-bg, #fff);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius);
  box-shadow: var(--mad-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.08));
  padding: 12px 14px;
}
.mad-password-strength-title {
  margin: 0 0 8px;
  font-size: var(--mad-text-sm);
  font-weight: 600;
  color: var(--mad-text);
}
.mad-password-strength-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mad-password-strength-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--mad-text-sm);
  color: var(--mad-text-muted);
  transition: color var(--mad-transition);
}
.mad-password-strength-list li.mad-pwd-rule-ok {
  color: var(--mad-success, #16a34a);
}

/* mad-btn loading state — aplicado por mad-livewire.js durante submit
   (esconde o conteudo do botao e mostra um spinner centralizado por cima) */
.mad-btn-loading-active {
  position: relative;
  cursor: progress;
  pointer-events: none;
  color: transparent !important;
}
.mad-btn-loading-active > * {
  visibility: hidden;
}
.mad-btn-loading-active::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: mad-spin .65s linear infinite;
  /* currentColor herda da cor do texto. Como zeramos color: transparent,
     usamos uma cor explicita pra garantir visibilidade em todas as variants */
  border-color: rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  opacity: 0.95;
}
/* Variants outline/ghost/secondary tem fundo claro: spinner precisa ser escuro */
.mad-btn-outline.mad-btn-loading-active::after,
.mad-btn-ghost.mad-btn-loading-active::after,
.mad-btn-secondary.mad-btn-loading-active::after {
  border-color: rgba(0, 0, 0, 0.18);
  border-top-color: rgba(0, 0, 0, 0.65);
}

/* color-field — input hex + swatch nativo colado à direita */
.mad-colorfield-wrap {
  display: flex;
  align-items: stretch;
  width: 100%;
}
.mad-colorfield-input {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  border-right: none !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
}
.mad-colorfield-swatch {
  flex-shrink: 0;
  width: 38px;
  padding: 0;
  border: 1.5px solid var(--mad-border);
  border-top-right-radius: var(--mad-radius);
  border-bottom-right-radius: var(--mad-radius);
  cursor: pointer;
  background-image:
    linear-gradient(45deg, #ddd 25%, transparent 25%),
    linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%),
    linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
}
.mad-colorfield-swatch:focus-visible {
  outline: 2px solid var(--mad-primary);
  outline-offset: 1px;
}
.mad-colorfield-swatch:disabled { cursor: not-allowed; opacity: 0.6; }
.pcr-app { z-index: 10100 !important; }

/* ============================================================
 * Icon Field (mad-icon-field) — picker de icones Lucide
 * ============================================================ */
.mad-iconfield-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.mad-iconfield-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--mad-input-height, 38px);
  padding: 4px 10px;
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius, 6px);
  background: var(--mad-input-bg, var(--mad-bg));
  color: var(--mad-text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.mad-iconfield-trigger:hover:not(:disabled) {
  border-color: var(--mad-border-hover, var(--mad-primary));
}
.mad-iconfield-trigger:focus-visible {
  outline: none;
  border-color: var(--mad-primary);
  box-shadow: 0 0 0 3px var(--mad-primary-subtle, rgba(79,70,229,0.18));
}
.mad-iconfield-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  background: var(--mad-bg-muted);
}
.mad-iconfield-trigger.mad-input-error {
  border-color: var(--mad-danger);
}

.mad-iconfield-preview {
  width: 28px; height: 28px;
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--mad-radius, 6px);
  background: var(--mad-bg-subtle, var(--mad-bg-muted));
  color: var(--mad-text);
}
.mad-iconfield-preview i,
.mad-iconfield-preview svg { width: 18px; height: 18px; }
.mad-iconfield-empty-icon { opacity: 0.35; }

.mad-iconfield-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.875rem;
  color: var(--mad-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mad-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}
.mad-iconfield-name-empty {
  color: var(--mad-text-muted, var(--mad-muted-fg));
  font-family: var(--mad-font, inherit);
}
.mad-iconfield-caret {
  color: var(--mad-muted-fg);
  display: inline-flex;
  flex: 0 0 auto;
}
.mad-iconfield-caret i,
.mad-iconfield-caret svg { width: 16px; height: 16px; }

/* Sizes */
.mad-iconfield-size-sm .mad-iconfield-trigger { min-height: 30px; padding: 2px 8px; gap: 8px; }
.mad-iconfield-size-sm .mad-iconfield-preview { width: 22px; height: 22px; flex-basis: 22px; }
.mad-iconfield-size-sm .mad-iconfield-preview i,
.mad-iconfield-size-sm .mad-iconfield-preview svg { width: 14px; height: 14px; }
.mad-iconfield-size-sm .mad-iconfield-name { font-size: 0.8125rem; }

.mad-iconfield-size-lg .mad-iconfield-trigger { min-height: 46px; padding: 6px 12px; gap: 12px; }
.mad-iconfield-size-lg .mad-iconfield-preview { width: 36px; height: 36px; flex-basis: 36px; }
.mad-iconfield-size-lg .mad-iconfield-preview i,
.mad-iconfield-size-lg .mad-iconfield-preview svg { width: 22px; height: 22px; }
.mad-iconfield-size-lg .mad-iconfield-name { font-size: 0.9375rem; }

/* Popover */
.mad-iconfield-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 320px;
  max-width: 520px;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-lg, 8px);
  box-shadow: var(--mad-shadow-xl, 0 14px 40px rgba(0,0,0,0.18));
  z-index: 1050;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mad-iconfield-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--mad-border);
  background: var(--mad-bg);
}
.mad-iconfield-search > i,
.mad-iconfield-search > svg { width: 16px; height: 16px; color: var(--mad-muted-fg); flex: 0 0 auto; }
.mad-iconfield-search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  color: var(--mad-text);
}
.mad-iconfield-search input::placeholder { color: var(--mad-text-muted, var(--mad-muted-fg)); }

.mad-iconfield-clear-btn {
  background: none;
  border: 0;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: var(--mad-muted-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mad-iconfield-clear-btn:hover { color: var(--mad-danger); background: var(--mad-bg-hover); }
.mad-iconfield-clear-btn i,
.mad-iconfield-clear-btn svg { width: 14px; height: 14px; }

/* Tabs */
.mad-iconfield-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--mad-border);
  background: var(--mad-bg-subtle, var(--mad-bg));
}
.mad-iconfield-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 0;
  background: transparent;
  border-radius: var(--mad-radius, 6px);
  cursor: pointer;
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--mad-text-muted, var(--mad-muted-fg));
  transition: background .12s, color .12s;
}
.mad-iconfield-tabs button:hover { background: var(--mad-bg-hover); color: var(--mad-text); }
.mad-iconfield-tabs button.is-active {
  background: var(--mad-primary-subtle, var(--mad-primary-light));
  color: var(--mad-primary);
  font-weight: 500;
}
.mad-iconfield-tabs button i,
.mad-iconfield-tabs button svg { width: 13px; height: 13px; }
.mad-iconfield-count {
  font-size: 0.6875rem;
  background: var(--mad-bg-muted);
  color: var(--mad-muted-fg);
  padding: 1px 6px;
  border-radius: var(--mad-radius-full, 999px);
  margin-left: 2px;
}
.mad-iconfield-tabs button.is-active .mad-iconfield-count {
  background: var(--mad-primary);
  color: var(--mad-primary-fg, #fff);
}

/* Grid */
.mad-iconfield-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 4px;
  padding: 10px;
  max-height: 320px;
  min-height: 120px;
  overflow-y: auto;
  background: var(--mad-bg);
  scrollbar-width: thin;
}
.mad-iconfield-grid::-webkit-scrollbar { width: 8px; }
.mad-iconfield-grid::-webkit-scrollbar-thumb { background: var(--mad-border); border-radius: 4px; }
.mad-iconfield-grid::-webkit-scrollbar-thumb:hover { background: var(--mad-border-strong, var(--mad-muted-fg)); }

.mad-iconfield-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--mad-radius, 6px);
  background: transparent;
  cursor: pointer;
  color: var(--mad-text);
  padding: 0;
  transition: background .1s, border-color .1s, transform .1s;
}
.mad-iconfield-cell:hover {
  background: var(--mad-bg-hover);
  border-color: var(--mad-border);
}
.mad-iconfield-cell.is-cursor {
  background: var(--mad-bg-hover);
  box-shadow: 0 0 0 2px var(--mad-primary);
}
.mad-iconfield-cell.is-selected {
  background: var(--mad-primary-subtle, var(--mad-primary-light));
  border-color: var(--mad-primary);
  color: var(--mad-primary);
}
.mad-iconfield-cell.is-selected.is-cursor {
  box-shadow: 0 0 0 2px var(--mad-primary);
}
.mad-iconfield-cell:active { transform: scale(0.94); }
.mad-iconfield-cell i,
.mad-iconfield-cell svg { width: 18px; height: 18px; }

.mad-iconfield-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px 16px;
  color: var(--mad-text-muted, var(--mad-muted-fg));
  text-align: center;
}
.mad-iconfield-empty i,
.mad-iconfield-empty svg { width: 28px; height: 28px; opacity: 0.5; }
.mad-iconfield-empty p { margin: 0; font-size: 0.875rem; }
.mad-iconfield-empty small { font-size: 0.75rem; opacity: 0.7; font-family: var(--mad-font-mono, monospace); }

/* Footer */
.mad-iconfield-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--mad-border);
  background: var(--mad-bg-subtle, var(--mad-bg));
  font-size: 0.75rem;
  color: var(--mad-text-muted, var(--mad-muted-fg));
}
.mad-iconfield-stats { display: inline-flex; align-items: baseline; gap: 4px; }
.mad-iconfield-stats-extra { opacity: 0.7; font-size: 0.6875rem; }
.mad-iconfield-clear-all {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--mad-danger);
  font: inherit;
  font-size: 0.75rem;
  padding: 4px 6px;
  border-radius: 4px;
}
.mad-iconfield-clear-all:hover { background: var(--mad-danger-subtle, rgba(220,38,38,0.1)); }
.mad-iconfield-clear-all i,
.mad-iconfield-clear-all svg { width: 13px; height: 13px; }

/* Date range picker (v2) — trigger, popup, presets, calendars */
.mad-drp-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--mad-input-height, 38px);
  padding: 0 10px;
  border: 1.5px solid var(--mad-border);
  border-radius: var(--mad-radius);
  background: var(--mad-bg);
  cursor: pointer;
  transition: border-color var(--mad-transition), box-shadow var(--mad-transition);
  position: relative;
  user-select: none;
}
.mad-drp-trigger:hover { border-color: var(--mad-border-hover, var(--mad-primary)); }
.mad-drp-trigger--open {
  border-color: var(--mad-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mad-primary) 12%, transparent);
}
.mad-drp-trigger--empty .mad-drp-display { color: var(--mad-text-muted); }
.mad-drp-display {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--mad-text);
  line-height: 1;
}
.mad-drp-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  padding: 0;
  color: var(--mad-text-muted);
  cursor: pointer;
  border-radius: 50%;
  transition: background var(--mad-transition), color var(--mad-transition);
  flex-shrink: 0;
}
.mad-drp-clear:hover {
  background: var(--mad-bg-muted);
  color: var(--mad-danger, #ef4444);
}

/* Popup */
.mad-drp-popup {
  position: absolute;
  top: calc(100% + 4px);
  z-index: 50;
  display: flex;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: 12px;
  box-shadow: 0 20px 60px -12px rgba(0,0,0,.18), 0 8px 20px -8px rgba(0,0,0,.1);
  overflow: hidden;
}
.mad-drp-popup--left  { left: 0; }
.mad-drp-popup--right { right: 0; }
.mad-drp-popup--center { left: 50%; transform: translateX(-50%); }

/* Transitions */
.mad-drp-enter { transition: opacity 150ms ease, transform 150ms ease; }
.mad-drp-enter-start { opacity: 0; transform: translateY(-4px); }
.mad-drp-enter-end { opacity: 1; transform: translateY(0); }
.mad-drp-leave { transition: opacity 100ms ease, transform 100ms ease; }
.mad-drp-leave-start { opacity: 1; transform: translateY(0); }
.mad-drp-leave-end { opacity: 0; transform: translateY(-4px); }
.mad-drp-popup--center .mad-drp-enter-start { transform: translateX(-50%) translateY(-4px); }
.mad-drp-popup--center .mad-drp-enter-end   { transform: translateX(-50%) translateY(0); }
.mad-drp-popup--center .mad-drp-leave-start { transform: translateX(-50%) translateY(0); }
.mad-drp-popup--center .mad-drp-leave-end   { transform: translateX(-50%) translateY(-4px); }

/* Presets sidebar */
.mad-drp-presets {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
  border-right: 1px solid var(--mad-border);
  min-width: 150px;
  max-width: 170px;
}
.mad-drp-preset {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--mad-text);
  border: none;
  background: none;
  border-radius: var(--mad-radius);
  cursor: pointer;
  transition: background var(--mad-transition), color var(--mad-transition);
  white-space: nowrap;
  line-height: 1.3;
}
.mad-drp-preset:hover {
  background: var(--mad-bg-subtle, var(--mad-bg-muted));
  color: var(--mad-primary);
}
.mad-drp-preset--active {
  background: color-mix(in srgb, var(--mad-primary) 10%, transparent);
  color: var(--mad-primary);
  font-weight: 500;
}

/* Calendars container */
.mad-drp-calendars {
  display: flex;
  gap: 8px;
  padding: 16px;
}
.mad-drp-cal {
  width: 260px;
}

/* Calendar navigation */
.mad-drp-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 2px;
}
.mad-drp-month-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--mad-text);
  user-select: none;
}
.mad-drp-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  padding: 0;
  color: var(--mad-text-muted);
  cursor: pointer;
  border-radius: var(--mad-radius);
  transition: background var(--mad-transition), color var(--mad-transition);
}
.mad-drp-nav-btn:hover {
  background: var(--mad-bg-muted);
  color: var(--mad-text);
}

/* Weekdays header */
.mad-drp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 4px;
}
.mad-drp-weekdays span {
  font-size: 11px;
  font-weight: 500;
  color: var(--mad-text-muted);
  padding: 4px 0;
  user-select: none;
}

/* Days grid */
.mad-drp-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.mad-drp-day {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  max-height: 36px;
  font-size: 13px;
  color: var(--mad-text);
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: 0;
  transition: background 80ms ease, color 80ms ease;
  position: relative;
}
.mad-drp-day:hover:not(:disabled):not(.mad-drp-day--other) {
  background: var(--mad-bg-muted);
}

/* Day states */
.mad-drp-day--other {
  color: var(--mad-text-subtle);
  opacity: 0.3;
  pointer-events: none;
}
.mad-drp-day--today {
  font-weight: 700;
  color: var(--mad-primary);
}
.mad-drp-day--today::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--mad-primary);
}
.mad-drp-day--disabled {
  opacity: 0.25;
  pointer-events: none;
  cursor: not-allowed;
}

/* Range highlighting */
.mad-drp-day--in-range {
  background: color-mix(in srgb, var(--mad-primary) 10%, transparent);
  color: var(--mad-text);
  border-radius: 0;
}
.mad-drp-day--start {
  background: var(--mad-primary);
  color: #fff;
  border-radius: 9999px 0 0 9999px;
}
.mad-drp-day--end {
  background: var(--mad-primary);
  color: #fff;
  border-radius: 0 9999px 9999px 0;
}
.mad-drp-day--start.mad-drp-day--end {
  border-radius: 9999px;
}
.mad-drp-day--start::after,
.mad-drp-day--end::after {
  display: none;
}
.mad-drp-day--start:hover,
.mad-drp-day--end:hover {
  background: var(--mad-primary);
  filter: brightness(1.1);
}

/* Mobile — bottom sheet */
@media (max-width: 768px) {
  .mad-drp-popup {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .mad-drp-popup::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--mad-border);
    border-radius: 4px;
    margin: 10px auto 4px;
    flex-shrink: 0;
  }
  .mad-drp-presets {
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    border-right: none;
    border-bottom: 1px solid var(--mad-border);
    padding: 8px 12px;
    gap: 6px;
    min-width: 0;
    max-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .mad-drp-preset {
    flex-shrink: 0;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--mad-border);
    font-size: 12px;
  }
  .mad-drp-preset--active {
    border-color: var(--mad-primary);
  }
  .mad-drp-calendars {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px 20px;
  }
  .mad-drp-cal {
    width: 100%;
  }
  .mad-drp-day {
    max-height: 42px;
    font-size: 14px;
  }

  /* Mobile transitions (slide up) */
  .mad-drp-enter-start { opacity: 0; transform: translateY(100%) !important; }
  .mad-drp-enter-end   { opacity: 1; transform: translateY(0) !important; }
  .mad-drp-leave-start { opacity: 1; transform: translateY(0) !important; }
  .mad-drp-leave-end   { opacity: 0; transform: translateY(100%) !important; }
  .mad-drp-enter { transition: opacity 200ms ease, transform 250ms cubic-bezier(0.16, 1, 0.3, 1) !important; }
  .mad-drp-leave { transition: opacity 150ms ease, transform 200ms ease !important; }
}


/* ═══════════════════════════════════════════════════════════════════
   44. COMPONENTE — SEARCH FIELD
   ═══════════════════════════════════════════════════════════════════ */

.mad-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.mad-search-icon {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--mad-text-subtle);
  pointer-events: none;
  flex-shrink: 0;
}
.mad-search-input { padding-left: 32px !important; padding-right: 32px !important; }
.mad-search-clear {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--mad-text-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: var(--mad-radius-sm);
  transition: color var(--mad-t);
}
.mad-search-clear:hover { color: var(--mad-text); }


/* ═══════════════════════════════════════════════════════════════════
   45. COMPONENTE — RANGE SLIDER
   ═══════════════════════════════════════════════════════════════════ */

.mad-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--mad-bg-muted);
  border-radius: var(--mad-radius-full);
  outline: none;
  cursor: pointer;
  border: 1.5px solid var(--mad-border);
}
.mad-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--mad-primary);
  cursor: pointer;
  border: 2px solid var(--mad-bg);
  box-shadow: 0 0 0 2px var(--mad-primary);
  transition: box-shadow var(--mad-t);
}
.mad-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--mad-primary);
  cursor: pointer;
  border: 2px solid var(--mad-bg);
  box-shadow: 0 0 0 2px var(--mad-primary);
}
.mad-range:focus-visible { outline: 2px solid var(--mad-primary); outline-offset: 3px; }
.mad-range:disabled { opacity: .5; cursor: not-allowed; }


/* ═══════════════════════════════════════════════════════════════════
   46. COMPONENTE — COLOR PICKER
   ═══════════════════════════════════════════════════════════════════ */

.mad-color-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--mad-border);
  border-radius: var(--mad-radius);
  padding: 6px 12px;
  background: var(--mad-bg);
  cursor: pointer;
  transition: border-color var(--mad-t);
  width: 100%;
}
.mad-color-wrap:hover { border-color: var(--mad-border-strong); }

.mad-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: var(--mad-radius-sm);
  border: 1px solid rgba(0,0,0,.1);
  flex-shrink: 0;
}
.mad-color-hex {
  font-size: var(--mad-text-sm);
  font-family: var(--mad-font-mono);
  color: var(--mad-text);
  flex: 1;
}
.mad-color-input {
  opacity: 0;
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}


/* ═══════════════════════════════════════════════════════════════════
   47. COMPONENTE — FILE UPLOAD
   ═══════════════════════════════════════════════════════════════════ */

.mad-file-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--mad-border);
  border-radius: var(--mad-radius-md);
  padding: 24px 16px;
  background: var(--mad-bg-subtle);
  cursor: pointer;
  transition: border-color var(--mad-t), background var(--mad-t);
  text-align: center;
}
.mad-file-wrap:hover {
  border-color: var(--mad-border-strong);
  background: var(--mad-bg-muted);
}
.mad-file-over {
  border-color: var(--mad-primary) !important;
  background: color-mix(in srgb, var(--mad-primary) 5%, transparent) !important;
}
.mad-file-error { border-color: var(--mad-danger) !important; }

.mad-file-input { display: none; }

.mad-file-wrap .mad-file-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  cursor: pointer;
}
.mad-file-text { font-size: var(--mad-text-sm); color: var(--mad-text-muted); }
.mad-file-text strong { color: var(--mad-primary); }
.mad-file-selected { color: var(--mad-text); font-weight: 600; }
.mad-file-hint { font-size: var(--mad-text-xs); color: var(--mad-text-subtle); }

/* File field — card preview (arquivo selecionado) */
.mad-file-card {
  width: 100%;
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-md);
  background: var(--mad-bg);
  overflow: hidden;
}
.mad-file-card-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  background: var(--mad-bg-muted);
  cursor: pointer;
  transition: opacity .15s;
}
.mad-file-card-thumb:hover { opacity: .85; }
.mad-file-card-img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
}
.mad-file-card-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 4px;
}
.mad-file-card-icon svg { width: 36px; height: 36px; color: var(--mad-text-muted); }
.mad-file-card-icon span { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--mad-text-muted); letter-spacing: .5px; }
.mad-file-card-body {
  padding: 10px 12px;
  border-top: 1px solid var(--mad-border);
}
.mad-file-card-name {
  display: block;
  font-size: var(--mad-text-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mad-file-card-size { font-size: var(--mad-text-xs); color: var(--mad-text-muted); }
.mad-file-card-toolbar {
  display: flex;
  border-top: 1px solid var(--mad-border);
  background: var(--mad-bg-subtle);
}
.mad-file-card-toolbar button,
.mad-file-card-toolbar a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 4px;
  border: none;
  background: none;
  color: var(--mad-text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.mad-file-card-toolbar button:hover,
.mad-file-card-toolbar a:hover {
  background: var(--mad-bg-muted);
  color: var(--mad-text);
}
.mad-file-card-toolbar button + button,
.mad-file-card-toolbar button + a,
.mad-file-card-toolbar a + button {
  border-left: 1px solid var(--mad-border);
}
.mad-file-card-toolbar svg { width: 13px; height: 13px; }
.mad-file-card-toolbar-danger { color: var(--mad-danger) !important; }
.mad-file-card-toolbar-danger:hover { background: color-mix(in srgb, var(--mad-danger) 8%, transparent) !important; }

/* ═══════════════════════════════════════════════════════
   PAGE LAYOUT (page-container / page-header / page-content)
   ═══════════════════════════════════════════════════════ */

.mad-page-container {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  padding: 20px 24px 16px;
  width: 100%;
  box-sizing: border-box;
  min-height: calc(100vh - 200px);
}

/* Header */
.mad-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: nowrap;
  width: 100%;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid #e5e7eb;
}
.mad-page-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.mad-page-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #71717a;
  font-size: 16px;
}
.mad-page-header-vsep {
  flex-shrink: 0;
  width: 1px;
  height: 32px;
  background: #e5e7eb;
}
.mad-page-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: #71717a;
  margin-bottom: 2px;
  font-weight: 400;
  line-height: 1.4;
}
.mad-page-breadcrumb svg {
  width: 5px;
  height: 8px;
  margin: 0 2px;
  color: #a1a1aa;
}
.mad-page-title {
  font-size: 20px;
  font-weight: 600;
  color: #18181b;
  letter-spacing: -0.025em;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
  padding: 0;
}
.mad-page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.mad-page-header-sep {
  display: none; /* separator is now border-bottom on .mad-page-header */
}

/* Content */
.mad-page-content {}
.mad-page-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.mad-page-body {}

/* ─────────────────────────────────────────────────────────
   PAGE LAYOUT — Variant: STRIPE
   Classe no body: .mad-layout-stripe
   Visual: barra accent fina no topo do container, sem borda
   lateral, ícone inline (sem caixa), separador vertical
   escondido, breadcrumb sutil, visual limpo arejado.
   Inspiração: Stripe, Linear, Vercel dashboards.
   ───────────────────────────────────────────────────────── */

.mad-layout-stripe .mad-page-container {
  background: var(--mad-bg, #fff);
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  padding: 0;
  overflow: hidden;
  position: relative;
}
.mad-layout-stripe .mad-page-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    var(--mad-accent, var(--mad-primary, #18181b)),
    color-mix(in srgb, var(--mad-accent, var(--mad-primary, #18181b)) 60%, #6366f1));
  z-index: 1;
}
.mad-layout-stripe .mad-page-header {
  padding: 20px 28px 16px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--mad-border, #e5e7eb);
}
.mad-layout-stripe .mad-page-header-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: none;
  background: color-mix(in srgb, var(--mad-accent, var(--mad-primary, #18181b)) 10%, transparent);
  color: var(--mad-accent, var(--mad-primary, #18181b));
}
.mad-layout-stripe .mad-page-header-icon svg,
.mad-layout-stripe .mad-page-header-icon i {
  width: 18px !important;
  height: 18px !important;
}
.mad-layout-stripe .mad-page-header-vsep {
  display: none;
}
.mad-layout-stripe .mad-page-breadcrumb {
  font-size: 12px;
  font-weight: 500;
  color: var(--mad-text-muted, #52525b);
  letter-spacing: .01em;
}
.mad-layout-stripe .mad-page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.03em;
}
.mad-layout-stripe .mad-page-header-actions .mad-btn {
  border-radius: 8px;
}
.mad-layout-stripe .mad-page-header-sep {
  display: none;
}
.mad-layout-stripe .mad-page-content {
  padding: 24px 28px 20px;
}

/* ─────────────────────────────────────────────────────────
   PAGE LAYOUT — Variant: DOCK
   Classe no body: .mad-layout-dock
   Visual: header compacto como "dock" flutuante com backdrop
   blur dentro do card de conteúdo. Ícone redondo accent.
   Header incrustado no topo do content (sem separação).
   Estilo macOS / app nativo.
   ───────────────────────────────────────────────────────── */

.mad-layout-dock .mad-page-container {
  background: var(--mad-bg, #fff);
  border: 1px solid var(--mad-border, #e5e7eb);
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.02);
  padding: 12px;
  min-height: calc(100vh - 200px);
}
.mad-layout-dock .mad-page-header {
  background: var(--mad-bg-muted, #f4f4f5);
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  margin-bottom: 16px;
  gap: 12px;
}
.mad-layout-dock .mad-page-header-left {
  gap: 10px;
}
.mad-layout-dock .mad-page-header-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--mad-accent, var(--mad-primary, #18181b));
  color: #fff;
}
.mad-layout-dock .mad-page-header-icon svg,
.mad-layout-dock .mad-page-header-icon i {
  width: 15px !important;
  height: 15px !important;
}
.mad-layout-dock .mad-page-header-vsep {
  display: none;
}
.mad-layout-dock .mad-page-breadcrumb {
  font-size: 11px;
  font-weight: 500;
  color: var(--mad-text-subtle, #a1a1aa);
}
.mad-layout-dock .mad-page-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.mad-layout-dock .mad-page-header-actions .mad-btn {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--mad-radius-full, 9999px);
}
.mad-layout-dock .mad-page-header-sep {
  display: none;
}
.mad-layout-dock .mad-page-content {
  padding: 4px 8px 8px;
}

/* ─────────────────────────────────────────────────────────
   PAGE LAYOUT — Variant: GLASS
   Classe no body: .mad-layout-glass
   Visual: glassmorphism — header translúcido com backdrop-blur,
   sombras suaves com glow, bordas rgba, ícone com anel
   accent brilhante. Fundo do container com noise sutil.
   ───────────────────────────────────────────────────────── */

.mad-layout-glass .mad-page-container {
  background:
    linear-gradient(135deg, rgba(255,255,255,.92) 0%, rgba(255,255,255,.78) 100%);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 16px;
  box-shadow:
    0 4px 24px rgba(0,0,0,.06),
    0 1px 2px rgba(0,0,0,.04),
    inset 0 1px 0 rgba(255,255,255,.8);
  padding: 0;
  overflow: hidden;
}
.mad-layout-glass .mad-page-header {
  background: rgba(255,255,255,.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 18px 26px 16px;
  margin-bottom: 0;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.mad-layout-glass .mad-page-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1.5px solid color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 30%, transparent);
  background: color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 8%, white);
  color: var(--mad-accent, var(--mad-primary, #18181b));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 8%, transparent);
}
.mad-layout-glass .mad-page-header-vsep {
  background: rgba(0,0,0,.08);
}
.mad-layout-glass .mad-page-breadcrumb {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--mad-text-muted, #52525b);
}
.mad-layout-glass .mad-page-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.025em;
}
.mad-layout-glass .mad-page-header-actions .mad-btn {
  border-radius: 10px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.mad-layout-glass .mad-page-header-actions .mad-btn-outline {
  background: rgba(255,255,255,.5);
  border-color: rgba(0,0,0,.1);
}
.mad-layout-glass .mad-page-header-actions .mad-btn-outline:hover {
  background: rgba(255,255,255,.8);
}
.mad-layout-glass .mad-page-header-sep {
  display: none;
}
.mad-layout-glass .mad-page-content {
  padding: 22px 26px 20px;
}

/* ─────────────────────────────────────────────────────────
   PAGE LAYOUT — Variant: BORDER
   Classe no body: .mad-layout-border
   Visual: borda accent grossa vertical à esquerda do container.
   Interior limpo e minimalista — ícone inline colorido sem caixa,
   sem separador vertical, sem sombra. Estilo Notion callout.
   ───────────────────────────────────────────────────────── */

.mad-layout-border .mad-page-container {
  background: var(--mad-bg, #fff);
  border: 1px solid var(--mad-border, #e5e7eb);
  border-left: 4px solid var(--mad-accent, var(--mad-primary, #18181b));
  border-radius: 4px 10px 10px 4px;
  box-shadow: none;
  padding: 0;
}
.mad-layout-border .mad-page-header {
  padding: 18px 24px 14px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--mad-border, #e5e7eb);
}
.mad-layout-border .mad-page-header-icon {
  width: auto;
  height: auto;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--mad-accent, var(--mad-primary, #18181b));
}
.mad-layout-border .mad-page-header-icon svg,
.mad-layout-border .mad-page-header-icon i {
  width: 22px !important;
  height: 22px !important;
  stroke-width: 2.2px;
}
.mad-layout-border .mad-page-header-vsep {
  display: none;
}
.mad-layout-border .mad-page-breadcrumb {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--mad-text-subtle, #a1a1aa);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.mad-layout-border .mad-page-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.mad-layout-border .mad-page-header-actions .mad-btn {
  border-radius: 6px;
}
.mad-layout-border .mad-page-header-sep {
  display: none;
}
.mad-layout-border .mad-page-content {
  padding: 20px 24px 18px;
}

/* ─────────────────────────────────────────────────────────
   PAGE LAYOUT — Variant: INSET
   Classe no body: .mad-layout-inset
   Visual: header com tint accent suave (wash de cor),
   content recuado com sombra inset dando profundidade.
   Ícone branco sobre fundo accent sólido. Header "elevado"
   acima do content — efeito de duas camadas.
   ───────────────────────────────────────────────────────── */

.mad-layout-inset .mad-page-container {
  background: var(--mad-bg, #fff);
  border: 1px solid var(--mad-border, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  padding: 0;
  overflow: hidden;
}
.mad-layout-inset .mad-page-header {
  background:
    color-mix(in srgb, var(--mad-accent, var(--mad-primary, #18181b)) 5%, white);
  padding: 18px 26px 16px;
  margin-bottom: 0;
  border-bottom: 1px solid
    color-mix(in srgb, var(--mad-accent, var(--mad-primary, #18181b)) 12%, transparent);
}
.mad-layout-inset .mad-page-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--mad-accent, var(--mad-primary, #18181b));
  color: #fff;
}
.mad-layout-inset .mad-page-header-vsep {
  background: color-mix(in srgb, var(--mad-accent, var(--mad-primary, #18181b)) 15%, transparent);
}
.mad-layout-inset .mad-page-breadcrumb {
  font-size: 12px;
  font-weight: 500;
  color: color-mix(in srgb, var(--mad-accent, var(--mad-primary, #18181b)) 50%, #52525b);
}
.mad-layout-inset .mad-page-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.025em;
}
.mad-layout-inset .mad-page-header-actions .mad-btn-primary {
  border-radius: 8px;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 30%, transparent);
}
.mad-layout-inset .mad-page-header-actions .mad-btn-outline {
  border-radius: 8px;
  border-color: color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 20%, transparent);
  color: var(--mad-text, #18181b);
}
.mad-layout-inset .mad-page-header-actions .mad-btn-outline:hover {
  background: color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 8%, transparent);
}
.mad-layout-inset .mad-page-header-sep {
  display: none;
}
.mad-layout-inset .mad-page-content {
  padding: 22px 26px 20px;
  background: var(--mad-bg-subtle, #fafafa);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.04);
}

/* ─────────────────────────────────────────────────────────
   PAGE LAYOUT — Variant: FLOAT
   Classe no body: .mad-layout-float
   Visual: header e body em cards separados ("islands"),
   ícone com fundo accent/gradiente, breadcrumb inline com
   separador dot, espaçamento generoso entre blocos.
   ───────────────────────────────────────────────────────── */

.mad-layout-float .mad-page-container {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mad-layout-float .mad-page-header {
  background: var(--mad-bg, #fff);
  border: 1px solid var(--mad-border, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 0 0 1px rgba(0,0,0,.02);
  padding: 16px 22px;
  margin-bottom: 0;
  border-bottom-color: var(--mad-border, #e5e7eb);
}
.mad-layout-float .mad-page-header-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 90%, white),
    color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 70%, black));
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 25%, transparent);
}
.mad-layout-float .mad-page-header-vsep {
  display: none;
}
.mad-layout-float .mad-page-breadcrumb {
  font-size: 12px;
  font-weight: 500;
  color: var(--mad-text-subtle, #a1a1aa);
  gap: 4px;
  margin-bottom: 3px;
}
.mad-layout-float .mad-page-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.03em;
}
.mad-layout-float .mad-page-header-actions .mad-btn {
  border-radius: 8px;
}
.mad-layout-float .mad-page-header-sep {
  display: none;
}
.mad-layout-float .mad-page-content {
  background: var(--mad-bg, #fff);
  border: 1px solid var(--mad-border, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 0 0 1px rgba(0,0,0,.02);
  padding: 22px 24px 18px;
  flex: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   DATAGRID VARIANTS — Overrides do mad-dg-* por layout variant.
   Cada variação ajusta toolbar, header, rows, footer e cards
   para harmonizar com o page layout correspondente.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Grid: STRIPE ─────────────────────────────────────── */
.mad-layout-stripe .mad-dg-wrap {
  border: none;
  border-radius: 0;
  overflow: visible;
}
.mad-layout-stripe .mad-dg-toolbar {
  background: transparent;
  border-bottom: 1px solid var(--mad-border);
  padding: 10px 0;
}
.mad-layout-stripe .mad-dg-th {
  background: transparent;
  border-bottom: 2px solid var(--mad-border);
  text-transform: none;
  font-size: 0.8rem;
  letter-spacing: 0;
  color: var(--mad-text-muted);
}
.mad-layout-stripe .mad-dg-head {
  background: transparent;
}
.mad-layout-stripe .mad-dg-row-even { background: transparent; }
.mad-layout-stripe .mad-dg-row-odd  { background: transparent; }
.mad-layout-stripe .mad-dg-row:hover td {
  background: color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 4%, transparent);
}
.mad-layout-stripe .mad-dg-cell {
  border-bottom: 1px solid var(--mad-border);
}
.mad-layout-stripe .mad-dg-footer {
  background: transparent;
  border-top: 1px solid var(--mad-border);
  padding: 10px 0;
}
.mad-layout-stripe .mad-dg-card {
  border-radius: 8px;
  border-color: var(--mad-border);
}

/* ── Grid: DOCK ───────────────────────────────────────── */
.mad-layout-dock .mad-dg-wrap {
  border: none;
  border-radius: 0;
}
.mad-layout-dock .mad-dg-toolbar {
  background: var(--mad-bg-muted);
  border-bottom: none;
  border-radius: 8px;
  margin-bottom: 8px;
  padding: 8px 12px;
}
.mad-layout-dock .mad-dg-search {
  border-radius: var(--mad-radius-full);
  height: 28px;
  font-size: 0.8rem;
}
.mad-layout-dock .mad-dg-th {
  background: transparent;
  border-bottom: 1px solid var(--mad-border);
  font-size: 0.75rem;
  padding: 6px 10px;
}
.mad-layout-dock .mad-dg-head {
  background: transparent;
}
.mad-layout-dock .mad-dg-cell {
  font-size: 0.82rem;
  padding: 8px 10px;
}
.mad-layout-dock .mad-dg-row-even { background: transparent; }
.mad-layout-dock .mad-dg-row-odd  { background: transparent; }
.mad-layout-dock .mad-dg-row:hover td {
  background: var(--mad-bg-muted);
}
.mad-layout-dock .mad-dg-footer {
  background: transparent;
  border-top: 1px solid var(--mad-border);
  padding: 8px 4px;
  font-size: 0.8rem;
}
.mad-layout-dock .mad-dg-card {
  border-radius: 10px;
}

/* ── Grid: GLASS ──────────────────────────────────────── */
.mad-layout-glass .mad-dg-wrap {
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 12px;
  background: rgba(255,255,255,.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow: hidden;
}
.mad-layout-glass .mad-dg-toolbar {
  background: rgba(255,255,255,.3);
  border-bottom-color: rgba(0,0,0,.06);
}
.mad-layout-glass .mad-dg-th {
  background: rgba(255,255,255,.25);
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.mad-layout-glass .mad-dg-head {
  background: transparent;
}
.mad-layout-glass .mad-dg-row-even { background: transparent; }
.mad-layout-glass .mad-dg-row-odd  { background: rgba(255,255,255,.2); }
.mad-layout-glass .mad-dg-row:hover td {
  background: rgba(255,255,255,.35);
}
.mad-layout-glass .mad-dg-footer {
  background: rgba(255,255,255,.25);
  border-top-color: rgba(0,0,0,.06);
}
.mad-layout-glass .mad-dg-card {
  background: rgba(255,255,255,.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-color: rgba(0,0,0,.06);
  border-radius: 12px;
}
.mad-layout-glass .mad-dg-card:hover {
  background: rgba(255,255,255,.7);
}

/* ── Grid: BORDER ─────────────────────────────────────── */
.mad-layout-border .mad-dg-wrap {
  border: none;
  border-radius: 0;
}
.mad-layout-border .mad-dg-toolbar {
  background: transparent;
  border-bottom: 1px solid var(--mad-border);
  padding: 8px 0;
}
.mad-layout-border .mad-dg-th {
  background: transparent;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: .05em;
  font-weight: 700;
  color: var(--mad-text-subtle);
  border-bottom: 2px solid var(--mad-border);
}
.mad-layout-border .mad-dg-head {
  background: transparent;
}
.mad-layout-border .mad-dg-row-even { background: transparent; }
.mad-layout-border .mad-dg-row-odd  { background: transparent; }
.mad-layout-border .mad-dg-row:hover td {
  background: color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 3%, transparent);
}
.mad-layout-border .mad-dg-cell {
  border-bottom: 1px solid var(--mad-border);
}
.mad-layout-border .mad-dg-footer {
  background: transparent;
  border-top: 1px solid var(--mad-border);
  padding: 10px 0;
}
.mad-layout-border .mad-dg-card {
  border-left: 3px solid var(--mad-accent, var(--mad-primary));
  border-radius: 2px 8px 8px 2px;
}

/* ── Grid: INSET ──────────────────────────────────────── */
.mad-layout-inset .mad-dg-wrap {
  border: none;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.04);
}
.mad-layout-inset .mad-dg-toolbar {
  background: var(--mad-bg);
  border-bottom: 1px solid var(--mad-border);
  padding: 10px 14px;
}
.mad-layout-inset .mad-dg-th {
  background: var(--mad-bg);
  border-bottom: 2px solid
    color-mix(in srgb, var(--mad-accent, var(--mad-primary)) 15%, var(--mad-border));
}
.mad-layout-inset .mad-dg-head {
  background: var(--mad-bg);
}
.mad-layout-inset .mad-dg-footer {
  background: var(--mad-bg);
  border-top: 1px solid var(--mad-border);
}
.mad-layout-inset .mad-dg-card {
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* ── Grid: FLOAT ──────────────────────────────────────── */
.mad-layout-float .mad-dg-wrap {
  border: none;
  border-radius: 0;
}
.mad-layout-float .mad-dg-toolbar {
  background: transparent;
  border-bottom: 1px solid var(--mad-border);
  padding: 10px 0;
}
.mad-layout-float .mad-dg-th {
  background: transparent;
  border-bottom: 1px solid var(--mad-border);
}
.mad-layout-float .mad-dg-head {
  background: transparent;
}
.mad-layout-float .mad-dg-row-even { background: transparent; }
.mad-layout-float .mad-dg-row-odd  { background: var(--mad-bg-subtle); }
.mad-layout-float .mad-dg-footer {
  background: transparent;
  border-top: 1px solid var(--mad-border);
  padding: 10px 0;
}
.mad-layout-float .mad-dg-card {
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 0 0 1px rgba(0,0,0,.02);
}

/* ── Grid Dark: all variants ──────────────────────────── */
.mad-dark .mad-dg-wrap {
  background: var(--mad-bg);
  border-color: var(--mad-border);
}
.mad-dark .mad-dg-toolbar {
  background: var(--mad-bg-subtle);
  border-bottom-color: var(--mad-border);
}
.mad-dark .mad-dg-th {
  background: var(--mad-bg-muted);
  color: var(--mad-text-subtle);
  border-bottom-color: var(--mad-border-strong);
}
.mad-dark .mad-dg-head {
  background: var(--mad-bg-muted);
}
.mad-dark .mad-dg-row-even { background: var(--mad-bg); }
.mad-dark .mad-dg-row-odd  { background: var(--mad-bg-subtle); }
.mad-dark .mad-dg-row:hover td {
  background: color-mix(in srgb, var(--mad-primary) 6%, transparent);
}
.mad-dark .mad-dg-cell {
  color: var(--mad-text);
  border-bottom-color: var(--mad-border);
}
.mad-dark .mad-dg-footer {
  background: var(--mad-bg-subtle);
  border-top-color: var(--mad-border);
}
.mad-dark .mad-dg-info {
  color: var(--mad-text-muted);
}
.mad-dark .mad-dg-per-page-label {
  color: var(--mad-text-subtle);
}
.mad-dark .mad-dg-action-btn {
  color: var(--mad-text-subtle);
}
.mad-dark .mad-dg-action-btn:hover {
  color: var(--mad-text);
  background: var(--mad-bg-muted);
}
.mad-dark .mad-dg-dropdown {
  background: var(--mad-bg-muted);
  border-color: var(--mad-border);
}
.mad-dark .mad-dg-dropdown-item {
  color: var(--mad-text);
}
.mad-dark .mad-dg-dropdown-item:hover {
  background: var(--mad-bg-subtle);
}
.mad-dark .mad-dg-export-menu {
  background: var(--mad-bg-muted);
  border-color: var(--mad-border);
}
.mad-dark .mad-dg-export-item {
  color: var(--mad-text);
}
.mad-dark .mad-dg-export-item:hover {
  background: var(--mad-bg-subtle);
}
.mad-dark .mad-dg-search {
  background: var(--mad-bg);
  border-color: var(--mad-border);
  color: var(--mad-text);
}
.mad-dark .mad-dg-card {
  background: var(--mad-bg-subtle);
  border-color: var(--mad-border);
}
.mad-dark .mad-dg-card:hover {
  border-color: var(--mad-border-strong);
}
.mad-dark .mad-dg-card-field-label {
  color: var(--mad-text-subtle);
}
.mad-dark .mad-dg-card-field-value {
  color: var(--mad-text);
}
.mad-dark .mad-dg-card-title {
  color: var(--mad-text);
}
.mad-dark .mad-dg-card-footer {
  border-top-color: var(--mad-border);
}
.mad-dark .mad-dg-card-action {
  color: var(--mad-text-muted);
}
.mad-dark .mad-dg-card-action:hover {
  color: var(--mad-text);
  background: var(--mad-bg-muted);
}
.mad-dark .mad-dg-view-btn {
  color: var(--mad-text-subtle);
  border-color: var(--mad-border);
}
.mad-dark .mad-dg-view-btn:hover {
  color: var(--mad-text);
  background: var(--mad-bg-muted);
}
.mad-dark .mad-dg-view-btn.active {
  background: var(--mad-bg-muted);
  color: var(--mad-text);
}
.mad-dark .mad-dg-filter-popover {
  background: var(--mad-bg-muted);
  border-color: var(--mad-border);
}
.mad-dark .mad-dg-filter-input {
  background: var(--mad-bg);
  border-color: var(--mad-border);
  color: var(--mad-text);
}
.mad-dark .mad-dg-col-chooser-panel {
  background: var(--mad-bg-muted);
  border-color: var(--mad-border);
}
.mad-dark .mad-select-sm {
  background: var(--mad-bg);
  border-color: var(--mad-border);
  color: var(--mad-text);
}

/* Dark + variant-specific grid overrides */
.mad-dark.mad-layout-stripe .mad-dg-toolbar,
.mad-dark .mad-layout-stripe .mad-dg-toolbar,
.mad-dark.mad-layout-stripe .mad-dg-footer,
.mad-dark .mad-layout-stripe .mad-dg-footer,
.mad-dark.mad-layout-stripe .mad-dg-th,
.mad-dark .mad-layout-stripe .mad-dg-th,
.mad-dark.mad-layout-stripe .mad-dg-head,
.mad-dark .mad-layout-stripe .mad-dg-head,
.mad-dark.mad-layout-border .mad-dg-toolbar,
.mad-dark .mad-layout-border .mad-dg-toolbar,
.mad-dark.mad-layout-border .mad-dg-footer,
.mad-dark .mad-layout-border .mad-dg-footer,
.mad-dark.mad-layout-border .mad-dg-th,
.mad-dark .mad-layout-border .mad-dg-th,
.mad-dark.mad-layout-border .mad-dg-head,
.mad-dark .mad-layout-border .mad-dg-head,
.mad-dark.mad-layout-float .mad-dg-toolbar,
.mad-dark .mad-layout-float .mad-dg-toolbar,
.mad-dark.mad-layout-float .mad-dg-footer,
.mad-dark .mad-layout-float .mad-dg-footer,
.mad-dark.mad-layout-float .mad-dg-th,
.mad-dark .mad-layout-float .mad-dg-th,
.mad-dark.mad-layout-float .mad-dg-head,
.mad-dark .mad-layout-float .mad-dg-head,
.mad-dark.mad-layout-dock .mad-dg-th,
.mad-dark .mad-layout-dock .mad-dg-th,
.mad-dark.mad-layout-dock .mad-dg-head,
.mad-dark .mad-layout-dock .mad-dg-head,
.mad-dark.mad-layout-dock .mad-dg-footer,
.mad-dark .mad-layout-dock .mad-dg-footer {
  background: transparent;
}
.mad-dark.mad-layout-dock .mad-dg-toolbar,
.mad-dark .mad-layout-dock .mad-dg-toolbar {
  background: var(--mad-bg-muted);
}
.mad-dark.mad-layout-glass .mad-dg-wrap,
.mad-dark .mad-layout-glass .mad-dg-wrap {
  background: rgba(255,255,255,.03);
  border-color: rgba(255,255,255,.06);
}
.mad-dark.mad-layout-glass .mad-dg-toolbar,
.mad-dark .mad-layout-glass .mad-dg-toolbar {
  background: rgba(255,255,255,.03);
  border-bottom-color: rgba(255,255,255,.06);
}
.mad-dark.mad-layout-glass .mad-dg-th,
.mad-dark .mad-layout-glass .mad-dg-th {
  background: rgba(255,255,255,.04);
  border-bottom-color: rgba(255,255,255,.08);
}
.mad-dark.mad-layout-glass .mad-dg-head,
.mad-dark .mad-layout-glass .mad-dg-head {
  background: transparent;
}
.mad-dark.mad-layout-glass .mad-dg-row-odd,
.mad-dark .mad-layout-glass .mad-dg-row-odd {
  background: rgba(255,255,255,.02);
}
.mad-dark.mad-layout-glass .mad-dg-row:hover td,
.mad-dark .mad-layout-glass .mad-dg-row:hover td {
  background: rgba(255,255,255,.06);
}
.mad-dark.mad-layout-glass .mad-dg-footer,
.mad-dark .mad-layout-glass .mad-dg-footer {
  background: rgba(255,255,255,.03);
  border-top-color: rgba(255,255,255,.06);
}
.mad-dark.mad-layout-glass .mad-dg-card,
.mad-dark .mad-layout-glass .mad-dg-card {
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.06);
}
.mad-dark.mad-layout-glass .mad-dg-card:hover,
.mad-dark .mad-layout-glass .mad-dg-card:hover {
  background: rgba(255,255,255,.08);
}
.mad-dark.mad-layout-inset .mad-dg-th,
.mad-dark .mad-layout-inset .mad-dg-th,
.mad-dark.mad-layout-inset .mad-dg-head,
.mad-dark .mad-layout-inset .mad-dg-head,
.mad-dark.mad-layout-inset .mad-dg-toolbar,
.mad-dark .mad-layout-inset .mad-dg-toolbar,
.mad-dark.mad-layout-inset .mad-dg-footer,
.mad-dark .mad-layout-inset .mad-dg-footer {
  background: var(--mad-bg-subtle);
}
.mad-dark.mad-layout-border .mad-dg-card,
.mad-dark .mad-layout-border .mad-dg-card {
  border-left-color: var(--mad-accent, var(--mad-primary));
}

/* ═══════════════════════════════════════════════════════
   DRAWER (slide-over panel)
   ═══════════════════════════════════════════════════════ */
.mad-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1010;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
}
.mad-drawer-overlay.mad-drawer-left {
  justify-content: flex-start;
}
.mad-drawer {
  background: var(--mad-bg);
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 100vw;
  overflow: hidden;
  box-shadow: -8px 0 32px rgba(0, 0, 0, .15);
}
.mad-drawer-left .mad-drawer {
  box-shadow: 8px 0 32px rgba(0, 0, 0, .15);
}
.mad-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--mad-border);
  flex-shrink: 0;
}
.mad-drawer-title {
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--mad-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mad-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ═══════════════════════════════════════════════════════════════════
   SPINNER FIELD (TSpinner)
   ═══════════════════════════════════════════════════════════════════ */
.mad-spinner-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--mad-border);
  background: var(--mad-bg);
  color: var(--mad-text);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.mad-spinner-btn:first-child {
  border-radius: var(--mad-radius-md) 0 0 var(--mad-radius-md);
  border-right: none;
}
.mad-spinner-btn:last-child {
  border-radius: 0 var(--mad-radius-md) var(--mad-radius-md) 0;
  border-left: none;
}
.mad-spinner-btn:hover:not(:disabled) {
  background: var(--mad-primary);
  color: #fff;
  border-color: var(--mad-primary);
}
.mad-spinner-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.mad-spinner-btn svg {
  width: 14px;
  height: 14px;
}
.mad-input-group .mad-input[type="number"] {
  -moz-appearance: textfield;
  border-radius: 0;
  flex: 1;
  text-align: center;
}
.mad-input-group .mad-input[type="number"]::-webkit-inner-spin-button,
.mad-input-group .mad-input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   CHECKBOX GROUP (TCheckGroup)
   ═══════════════════════════════════════════════════════════════════ */
.mad-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mad-checkbox-group-h {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px 20px;
}

/* ═══════════════════════════════════════════════════════════════════
   CHECKLIST (seleção múltipla com busca)
   ═══════════════════════════════════════════════════════════════════ */
.mad-checklist {
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-md);
  overflow: hidden;
}

/* Toolbar */
.mad-checklist-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--mad-border);
  background: var(--mad-bg-subtle);
}
.mad-checklist-search-wrap {
  position: relative; flex: 1;
}
.mad-checklist-search-icon {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  color: var(--mad-text-muted); pointer-events: none;
}
.mad-checklist-search {
  width: 100%; border: 1px solid var(--mad-border); border-radius: var(--mad-radius-sm);
  padding: 5px 8px 5px 28px; font-size: 0.82rem; background: var(--mad-bg);
  outline: none;
}
.mad-checklist-search:focus { border-color: var(--mad-primary); }
.mad-checklist-counter {
  font-size: 0.75rem; color: var(--mad-text-muted); white-space: nowrap;
}
.mad-checklist-filter-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-sm); background: transparent;
  color: var(--mad-text-muted); cursor: pointer; transition: all .15s;
  flex-shrink: 0;
}
.mad-checklist-filter-btn:hover { background: var(--mad-bg-subtle); color: var(--mad-text); }
.mad-checklist-filter-active {
  background: var(--mad-primary) !important; color: #fff !important;
  border-color: var(--mad-primary) !important;
}
.mad-checklist-select-all {
  display: flex; align-items: center; gap: 4px;
  font-size: 0.8rem; white-space: nowrap; cursor: pointer; margin: 0;
}

/* Body (scroll) */
.mad-checklist-body { overflow-y: auto; }

/* Table */
.mad-checklist-table {
  width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.mad-checklist-table th,
.mad-checklist-table td {
  padding: 7px 12px; border-bottom: 1px solid var(--mad-border); text-align: left;
}
.mad-checklist-table th {
  background: var(--mad-bg-subtle); font-weight: 600; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--mad-text-muted);
  position: sticky; top: 0; z-index: 1;
}
.mad-checklist-table th.center, .mad-checklist-table td.center { text-align: center; }
.mad-checklist-table th.right,  .mad-checklist-table td.right  { text-align: right; }
.mad-checklist-table tbody tr { transition: background .1s; }
.mad-checklist-table tbody tr:nth-child(even) { background: var(--mad-bg-subtle); }
.mad-checklist-table tbody tr:hover { background: rgba(59, 130, 246, 0.04); }
.mad-checklist-table tbody tr.mad-checklist-checked { background: rgba(59, 130, 246, 0.06); }
.mad-checklist-table tbody tr.mad-checklist-checked:nth-child(even) { background: rgba(59, 130, 246, 0.09); }
.mad-checklist-table tbody tr:last-child td { border-bottom: none; }

/* ═══════════════════════════════════════════════════════════════════
   MULTI-SEARCH / UNIQUE-SEARCH / MULTI-ENTRY (TomSelect)
   ═══════════════════════════════════════════════════════════════════ */
.ts-wrapper.mad-ts-error .ts-control {
  border-color: var(--mad-danger);
}

/* ═══════════════════════════════════════════════════════════════════
   NO-RESULTS block — "cadastrar novo" + "quick register" no dropdown
   do TomSelect ou abaixo de <mad-dbselect-field> (inline)
   ═══════════════════════════════════════════════════════════════════ */

/* Dentro do dropdown TomSelect (render.no_results) */
.ts-dropdown .mad-ts-noresults {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}
.ts-dropdown .mad-ts-noresults-msg {
  color: var(--mad-muted, #6b7280);
  font-size: 0.8125rem;
  padding: 4px 0 2px;
}
.ts-dropdown .mad-ts-noresults-btn {
  width: 100%;
  justify-content: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ts-dropdown .mad-ts-noresults-quick-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.ts-dropdown .mad-ts-noresults-quick-row > .mad-ts-noresults-quick-input {
  flex: 1;
  min-width: 0;
}
.ts-dropdown .mad-ts-noresults-quick-row > .mad-ts-noresults-btn {
  width: auto;
  flex-shrink: 0;
}
/* Mini-form vertical (modo multi-campo) */
.ts-dropdown .mad-ts-noresults-quick-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px dashed var(--mad-border, #e5e7eb);
  margin-top: 4px;
}
.ts-dropdown .mad-ts-noresults-quick-form .mad-ts-noresults-btn {
  width: 100%;
  margin-top: 2px;
}
.ts-dropdown .mad-ts-noresults-quick-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ts-dropdown .mad-ts-noresults-quick-field > .mad-label {
  font-size: 0.75rem;
  margin: 0;
  color: var(--mad-muted, #6b7280);
  font-weight: 500;
}
.ts-dropdown .mad-ts-noresults-quick-field .mad-input {
  width: 100%;
  font-size: 0.875rem;
  padding: 6px 8px;
}

/* Os .no-results do TomSelect (default) somem quando temos o bloco nosso */
.ts-dropdown .mad-ts-noresults ~ .no-results,
.ts-dropdown .no-results:has(.mad-ts-noresults) > *:not(.mad-ts-noresults) {
  display: none;
}

/* Bloco inline renderizado abaixo do select nativo (mad-dbselect-field) */
.mad-noresults-inline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.mad-noresults-inline .mad-noresults-msg {
  color: var(--mad-muted, #6b7280);
  font-size: 0.8125rem;
}
.mad-noresults-inline .mad-noresults-quick-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.mad-noresults-inline .mad-noresults-quick-row > .mad-noresults-quick-input {
  flex: 1;
  min-width: 0;
}
.mad-noresults-inline .mad-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Quick form multi-campo no modo inline (dbselect-field) */
.mad-noresults-inline .mad-noresults-quick-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  border: 1px dashed var(--mad-border, #e5e7eb);
  border-radius: var(--mad-radius-md, 6px);
  background: var(--mad-bg-muted, #f4f4f5);
}
.mad-noresults-inline .mad-noresults-quick-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.mad-noresults-inline .mad-noresults-quick-field > .mad-label {
  font-size: 0.75rem;
  margin: 0;
  color: var(--mad-muted, #6b7280);
  font-weight: 500;
}
.mad-noresults-inline .mad-noresults-quick-form .mad-btn {
  width: 100%;
  justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════════
   QUICK FORM POPOVER — flutuante ancorado no combo, melhor UX que
   renderizar o form dentro do dropdown apertado do TomSelect
   ═══════════════════════════════════════════════════════════════════ */
.mad-quick-popover {
  position: fixed;
  z-index: 10050; /* acima de modal/drawer (geralmente 10000) */
  min-width: 320px;
  max-width: 480px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--mad-bg, #fff);
  border: 1px solid var(--mad-border, #e5e7eb);
  border-radius: var(--mad-radius-lg, 10px);
  box-shadow: 0 20px 50px -12px rgba(15, 23, 42, 0.25),
              0 8px 24px -8px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  animation: madQuickPopIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes madQuickPopIn {
  from { opacity: 0; transform: scale(0.96) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.mad-quick-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--mad-border, #e5e7eb);
  background: var(--mad-bg-muted, #f4f4f5);
}
.mad-quick-popover-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--mad-text, #0f172a);
}
.mad-quick-popover-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  color: var(--mad-muted, #6b7280);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.mad-quick-popover-close:hover {
  background: var(--mad-border, #e5e7eb);
  color: var(--mad-text, #0f172a);
}
.mad-quick-popover-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
}
.mad-quick-popover-msg {
  font-size: 0.8125rem;
  color: var(--mad-muted, #6b7280);
  background: var(--mad-info-soft, #eff6ff);
  border-left: 3px solid var(--mad-info, #3b82f6);
  padding: 8px 12px;
  border-radius: 4px;
}
.mad-quick-popover-body .mad-noresults-quick-field,
.mad-quick-popover-body .mad-ts-noresults-quick-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mad-quick-popover-body .mad-noresults-quick-field > .mad-label,
.mad-quick-popover-body .mad-ts-noresults-quick-field > .mad-label {
  font-size: 0.8125rem;
  margin: 0;
  color: var(--mad-text, #0f172a);
  font-weight: 500;
}
.mad-quick-popover-body input.mad-input,
.mad-quick-popover-body select.mad-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.875rem;
}
.mad-quick-popover-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--mad-border, #e5e7eb);
  background: var(--mad-bg-muted, #f4f4f5);
}
/* Mobile — full-screen */
@media (max-width: 600px) {
  .mad-quick-popover {
    position: fixed;
    inset: auto 8px 8px 8px;
    top: auto !important;
    left: auto !important;
    width: auto;
    max-width: none;
    transform: none !important;
    max-height: 90vh;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   MULTI FILE (TMultiFile)
   ═══════════════════════════════════════════════════════════════════ */
.mad-multi-file-wrap {
  border: 2px dashed var(--mad-border);
  border-radius: var(--mad-radius-md);
  background: var(--mad-bg);
  transition: border-color 0.2s, background 0.2s;
}
.mad-multi-file-wrap.mad-multi-file-over {
  border-color: var(--mad-primary);
  background: color-mix(in srgb, var(--mad-primary) 5%, transparent);
}
.mad-multi-file-input {
  display: none;
}
.mad-multi-file-wrap .mad-file-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  color: var(--mad-muted);
  font-size: 0.9rem;
  gap: 4px;
  pointer-events: auto;
  cursor: pointer;
}
.mad-file-body strong {
  color: var(--mad-primary);
}
/* Multi-file — galeria de thumbnails */
.mad-multi-file-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--mad-border);
}
.mad-multi-file-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-md);
  background: var(--mad-bg);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.mad-multi-file-card:hover {
  border-color: var(--mad-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.mad-multi-file-card-img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
}
.mad-multi-file-card-icon {
  width: 100%;
  height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.mad-multi-file-card-icon svg { width: 28px; height: 28px; color: var(--mad-text-muted); }
.mad-multi-file-card-ext { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--mad-text-muted); letter-spacing: 0.5px; }
.mad-multi-file-card-info {
  padding: 6px 8px;
  border-top: 1px solid var(--mad-border);
}
.mad-multi-file-card-name {
  display: block;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--mad-text);
}
.mad-multi-file-card-size {
  font-size: 10px;
  color: var(--mad-text-muted);
}
.mad-multi-file-card-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0;
}
.mad-multi-file-card-remove svg { width: 12px; height: 12px; }
.mad-multi-file-card:hover .mad-multi-file-card-remove { opacity: 1; }
.mad-multi-file-card-add {
  border-style: dashed;
  min-height: 120px;
}
.mad-multi-file-card-add:hover {
  border-color: var(--mad-primary);
  background: color-mix(in srgb, var(--mad-primary) 3%, transparent);
}

/* Legacy list classes (backward compat) */
.mad-multi-file-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  border-top: 1px solid var(--mad-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mad-multi-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-sm);
  font-size: 0.875rem;
}
.mad-multi-file-item svg {
  width: 16px;
  height: 16px;
  color: var(--mad-primary);
  flex-shrink: 0;
}
.mad-multi-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mad-multi-file-size {
  color: var(--mad-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════
   SEEK FIELD (TSeekButton)
   ═══════════════════════════════════════════════════════════════════ */
.mad-seek-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  height: 38px;
  border: 1px solid var(--mad-border);
  border-left: none;
  background: var(--mad-bg);
  color: var(--mad-muted);
  cursor: pointer;
  border-radius: 0 var(--mad-radius-md) var(--mad-radius-md) 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  padding: 0;
}
.mad-seek-btn:hover:not(:disabled) {
  background: var(--mad-primary);
  color: #fff;
  border-color: var(--mad-primary);
}
.mad-seek-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.mad-seek-btn svg {
  width: 16px;
  height: 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   SORT LIST (TSortList)
   ═══════════════════════════════════════════════════════════════════ */
.mad-sort-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 48px;
}
.mad-sort-list-h {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}
.mad-sort-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-sm);
  font-size: 0.875rem;
  user-select: none;
}
.mad-sort-item.sortable-ghost {
  opacity: 0.4;
  background: color-mix(in srgb, var(--mad-primary) 10%, transparent);
}
.mad-sort-item.sortable-chosen {
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.mad-sort-handle {
  cursor: grab;
  color: var(--mad-muted);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.mad-sort-handle:active {
  cursor: grabbing;
}
.mad-sort-handle svg {
  width: 16px;
  height: 16px;
}
.mad-sort-label {
  flex: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   HTML EDITOR (TinyMCE 5 self-hosted)
   ═══════════════════════════════════════════════════════════════════ */
.mad-html-editor-wrap {
  border-radius: var(--mad-radius-md);
  overflow: hidden;
}
.mad-html-editor-wrap .tox-tinymce {
  border: 1px solid var(--mad-border) !important;
  border-radius: var(--mad-radius-md) !important;
  font-family: inherit !important;
}
.mad-html-editor-error .tox-tinymce {
  border-color: var(--mad-danger) !important;
}
.mad-html-editor-wrap .tox-editor-header {
  box-shadow: none !important;
  border-bottom: 1px solid var(--mad-border) !important;
}
.mad-html-editor-wrap .tox-statusbar {
  border-top: 1px solid var(--mad-border) !important;
}

/* ═══════════════════════════════════════════════════════════════════
   DATA GRID (MadDataGrid)
   ═══════════════════════════════════════════════════════════════════ */

/* Container geral */
.mad-dg-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-lg);
  /* overflow: hidden; */
}

/* ── Toolbar ──────────────────────────────────────────────────────── */
.mad-dg-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--mad-border);
  background: var(--mad-bg-subtle);
  flex-wrap: wrap;
}
.mad-dg-search {
  max-width: 220px;
  height: 30px;
  font-size: 0.82rem;
}
.mad-dg-toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* ── Export dropdown ──────────────────────────────────────────────── */
.mad-dg-export-wrap { position: relative; }
.mad-dg-export-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 50;
  background: var(--mad-bg); border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-md);
  box-shadow: var(--mad-shadow-lg, 0 8px 24px rgba(0,0,0,.12));
  padding: 4px; min-width: 130px;
}
.mad-dg-export-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border: none; background: none; cursor: pointer;
  font-size: 13px; border-radius: var(--mad-radius-sm); color: var(--mad-text);
}
.mad-dg-export-item:hover { background: var(--mad-bg-subtle); }

/* ── Autocomplete dropdown ───────────────────────────────────────── */
.mad-ac-dropdown {
  background: var(--mad-bg, #fff);
  border: 1px solid var(--mad-border, #e5e7eb);
  border-radius: var(--mad-radius-md, 6px);
  box-shadow: var(--mad-shadow-lg, 0 8px 24px rgba(0,0,0,.12));
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
}
.mad-ac-item {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  border-radius: var(--mad-radius-sm, 4px);
  color: var(--mad-text, #333);
}
.mad-ac-item:hover,
.mad-ac-item.mad-ac-active {
  background: var(--mad-primary, #3b82f6);
  color: #fff;
}

.mad-dg-info {
  font-size: 0.78rem;
  color: var(--mad-text-muted);
  white-space: nowrap;
}

/* ── Barra de filtros ativos ─────────────────────────────────────── */
.mad-dg-active-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--mad-border);
  background: var(--mad-bg-subtle);
}
.mad-dg-active-filters-label {
  font-size: 0.78rem;
  color: var(--mad-text-muted);
  white-space: nowrap;
}
.mad-dg-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 10px;
  border-radius: 999px;
  background: var(--mad-primary-light, #ede9fe);
  color: var(--mad-primary, #6d28d9);
  font-size: 0.78rem;
  border: 1px solid var(--mad-primary-muted, #c4b5fd);
}
.mad-dg-filter-pill strong {
  font-weight: 600;
}
.mad-dg-filter-pill-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 1px;
  border-radius: 50%;
  color: inherit;
  opacity: 0.7;
  line-height: 1;
}
.mad-dg-filter-pill-x:hover {
  opacity: 1;
  background: rgba(0,0,0,.08);
}
.mad-dg-clear-all {
  margin-left: 4px;
  font-size: 0.78rem;
  color: var(--mad-text-muted);
}
.mad-dg-clear-all:hover {
  color: var(--mad-danger, #dc2626);
}

/* ── Column chooser ──────────────────────────────────────────────── */
.mad-dg-col-chooser-wrap {
  position: relative;
  display: flex;
  justify-content: flex-end;
  height: 0;        /* sem altura — o panel flutua sobre a tabela */
  overflow: visible;
}
.mad-dg-col-chooser-panel {
  position: absolute;
  right: 0;
  top: 0;
  z-index: 200;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-md, 8px);
  box-shadow: var(--mad-shadow-md, 0 4px 16px rgba(0,0,0,.12));
  min-width: 180px;
  padding: 6px 0;
}
.mad-dg-col-chooser-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--mad-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--mad-border);
  margin-bottom: 4px;
}
.mad-dg-col-chooser-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 0.83rem;
  cursor: pointer;
  user-select: none;
  color: var(--mad-text);
}
.mad-dg-col-chooser-item:hover {
  background: var(--mad-bg-subtle);
}
.mad-dg-col-chooser-check {
  -webkit-appearance: checkbox !important;
  appearance: checkbox !important;
  accent-color: var(--mad-primary, #6d28d9);
  width: 14px !important;
  height: 14px !important;
  min-width: 14px !important;
  cursor: pointer;
  background: none !important;
  border: none !important;
}
.mad-dg-col-chooser-check::before {
  display: none !important;
}

/* ── Hidden column (column chooser) ─────────────────────────────── */
.mad-dg-col-hidden {
  display: none !important;
}

/* ── Table wrap ──────────────────────────────────────────────────── */
.mad-dg-table-wrap {
  overflow-x: auto;
  width: 100%;
}
.mad-dg-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
  /* offsets para sticky: ajuste se o thead mudar de altura */
  --mad-dg-thead-h:  41px;
  --mad-dg-group0-h: 37px;
}

/* ── Header ──────────────────────────────────────────────────────── */
.mad-dg-head {
  background: var(--mad-bg-muted);
}
.mad-dg-th {
  padding: 8px 12px;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--mad-text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--mad-bg-muted);
  border-bottom: 2px solid var(--mad-border-strong);
}
.mad-dg-th-filtered {
  background: color-mix(in srgb, var(--mad-primary) 6%, transparent);
}
.mad-dg-th-actions {
  text-align: center;
}
.mad-dg-th-chooser-only {
  width: 36px;
  padding: 4px 6px;
  text-align: center;
}
.mad-dg-th-content {
  display: flex;
  align-items: center;
  gap: 4px;
}
.mad-dg-th-label {
  flex: 1;
}
.mad-dg-col-group {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--mad-bg-subtle);
  border-bottom: 1px solid var(--mad-border);
}

/* Sort button */
.mad-dg-sort-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
  color: var(--mad-text-subtle);
  display: flex;
  align-items: center;
  line-height: 1;
  transition: color .15s;
}
.mad-dg-sort-btn:hover  { color: var(--mad-text); }
.mad-dg-sort-asc,
.mad-dg-sort-desc       { color: var(--mad-primary); }

/* Filter */
.mad-dg-filter-wrap {
  position: relative;
}
.mad-dg-filter-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
  color: var(--mad-text-subtle);
  display: flex;
  align-items: center;
  line-height: 1;
  transition: color .15s;
}
.mad-dg-filter-btn:hover    { color: var(--mad-primary); }
.mad-dg-filter-active       { color: var(--mad-primary) !important; }
.mad-dg-filter-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-md);
  box-shadow: var(--mad-shadow-lg, 0 8px 24px rgba(0,0,0,.12));
  padding: 10px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mad-dg-filter-input {
  width: 100%;
  font-size: 0.83rem;
}
.mad-dg-filter-clear {
  font-size: 0.78rem;
  color: var(--mad-text-muted);
}

/* Popover avançado (filter-popover) — mais largo, com botões e operador */
.mad-dg-filter-popover-advanced {
  min-width: 240px;
}
.mad-dg-filter-op {
  width: 100%;
  font-size: 0.83rem;
}
.mad-dg-filter-btns {
  display: flex;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--mad-border);
  margin-top: 2px;
}
.mad-dg-filter-btns .mad-btn {
  flex: 1;
  justify-content: center;
}

/* ── Body rows ───────────────────────────────────────────────────── */
.mad-dg-row-even { background: var(--mad-bg); }
.mad-dg-row-odd  { background: var(--mad-bg-subtle); }
.mad-dg-row:hover td { background: color-mix(in srgb, var(--mad-primary) 4%, transparent); }

/* ── Row highlight (manageRow update/insert) ─────────────────────── */
.mad-dg-row-highlight td {
  animation: mad-row-flash 2.5s ease-out;
}
@keyframes mad-row-flash {
  0%   { background-color: rgba(59, 130, 246, 0.15); }
  70%  { background-color: rgba(59, 130, 246, 0.08); }
  100% { background-color: transparent; }
}

.mad-dg-cell {
  padding: 8px 12px;
  vertical-align: middle;
  font-size: 0.84rem;
  color: var(--mad-text);
  border-bottom: 1px solid var(--mad-border);
}

/* Empty state */
.mad-dg-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--mad-text-subtle);
}
.mad-dg-empty-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

/* Ghost só existe para referência no DOM — proxies ficam no body com position:fixed */
.mad-dg-sticky-ghost { display: none; }

/* Thead proxy (tabela clonada com position:fixed) */
.mad-dg-thead-proxy {
  box-shadow: 0 2px 8px -2px rgba(0,0,0,.15);
  overflow: hidden;
}
.mad-dg-thead-proxy .mad-dg-th {
  position: static !important; /* anula sticky residual do clone */
}

/* Group proxies appended ao body pelo JS */
.mad-dg-sticky-proxy {
  align-items: center;
  background: var(--mad-bg, #fff);
  border-bottom: 1px solid var(--mad-border);
  box-shadow: 0 2px 6px -2px rgba(0,0,0,.10);
}
.mad-dg-sticky-proxy .mad-dg-group-cell {
  padding-top: 8px;
  padding-bottom: 8px;
  width: 100%;
}

/* Group rows */
.mad-dg-group-row {
  background: transparent !important;
}
.mad-dg-group-row > td {
  padding: 0 !important;
  border-bottom: none !important;
  /* sticky: cada nível fica abaixo do anterior */
  position: sticky;
  z-index: 3;
  background: var(--mad-bg, #fff);
}
.mad-dg-group-level-0 > td {
  top: var(--mad-dg-thead-h, 41px);
}
.mad-dg-group-level-1 > td {
  top: calc(var(--mad-dg-thead-h, 41px) + var(--mad-dg-group0-h, 37px));
  z-index: 2;
}

/* Conteúdo interno do cabeçalho de grupo */
.mad-dg-group-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 12px 4px;
  font-size: var(--mad-text-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--mad-text-subtle);
}
.mad-dg-group-level-0 .mad-dg-group-cell {
  padding-top: 18px;
  color: var(--mad-text-muted);
  font-size: var(--mad-text-sm);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  border-top: 1px solid var(--mad-border);
}
.mad-dg-group-level-0:first-child .mad-dg-group-cell {
  border-top: none;
  padding-top: 8px;
}
.mad-dg-group-level-1 .mad-dg-group-cell {
  color: var(--mad-text-subtle);
  font-size: var(--mad-text-xs);
  font-weight: 600;
  padding-top: 10px;
}
.mad-dg-group-icon {
  display: flex;
  align-items: center;
  opacity: 0.5;
  flex-shrink: 0;
}
.mad-dg-group-label {
  flex: 1;
}
.mad-dg-group-count {
  font-weight: 400;
  font-size: var(--mad-text-xs);
  color: var(--mad-text-subtle);
  background: var(--mad-bg-muted);
  border: 1px solid var(--mad-border);
  border-radius: 20px;
  padding: 1px 7px;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
}
.mad-dg-group-subtotals {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--mad-border);
  flex-shrink: 0;
}
.mad-dg-group-subtotal-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--mad-text-xs);
}
.mad-dg-group-subtotal-label {
  color: var(--mad-text-subtle);
  font-weight: 400;
}
.mad-dg-group-subtotal-value {
  color: var(--mad-text);
  font-weight: 600;
}

/* Indentação visual das linhas de dado por profundidade do grupo */
.mad-dg-row-depth-1 > td:first-child { padding-left: 20px !important; }
.mad-dg-row-depth-2 > td:first-child { padding-left: 32px !important; }
.mad-dg-row-depth-3 > td:first-child { padding-left: 44px !important; }

/* Linha vertical indicadora de hierarquia */
.mad-dg-row-depth-1 { box-shadow: inset 3px 0 0 var(--mad-border-strong); }
.mad-dg-row-depth-2 { box-shadow: inset 4px 0 0 var(--mad-border); }

/* Totais por grupo */
.mad-dg-group-total {
  background: transparent !important;
  font-weight: 600;
}
.mad-dg-group-total td {
  border-top: 1px dashed var(--mad-border) !important;
  border-bottom: 2px solid var(--mad-border) !important;
  color: var(--mad-text-muted);
  font-size: var(--mad-text-sm);
}
.mad-dg-group-total-level-1 td {
  border-top: 1px dashed var(--mad-border) !important;
  border-bottom: 1px solid var(--mad-border-strong) !important;
  font-weight: 500;
}

/* ── Actions column ──────────────────────────────────────────────── */
.mad-dg-actions-cell {
  padding: 4px 8px;
}
.mad-dg-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
}
.mad-dg-action-btn {
  background: none;
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-sm);
  cursor: pointer;
  padding: 4px 6px;
  color: var(--mad-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  transition: background .15s, color .15s, border-color .15s;
}
.mad-dg-action-btn:hover {
  background: var(--mad-bg-muted);
  color: var(--mad-text);
  border-color: var(--mad-border-strong);
}
.mad-dg-action-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.mad-dg-action-btn-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
}
.mad-dg-action-btn-label {
  font-size: 0.78rem;
  white-space: nowrap;
}
.mad-dg-action-danger {
  color: var(--mad-danger);
  border-color: color-mix(in srgb, var(--mad-danger) 25%, transparent);
}
.mad-dg-action-danger:hover {
  background: color-mix(in srgb, var(--mad-danger) 8%, transparent);
  border-color: var(--mad-danger);
  color: var(--mad-danger);
}
.mad-dg-action-primary {
  color: var(--mad-primary);
  border-color: color-mix(in srgb, var(--mad-primary) 30%, transparent);
}
.mad-dg-action-primary:hover {
  background: color-mix(in srgb, var(--mad-primary) 8%, transparent);
  border-color: var(--mad-primary);
  color: var(--mad-primary);
}

/* Dropdown */
.mad-dg-dropdown-wrap {
  position: relative;
}
.mad-dg-dropdown {
  position: fixed;
  z-index: 9999;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-md);
  box-shadow: var(--mad-shadow-lg, 0 8px 24px rgba(0,0,0,.12));
  min-width: 160px;
  overflow: hidden;
}
.mad-dg-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  font-size: 0.83rem;
  color: var(--mad-text);
  text-align: left;
  transition: background .12s;
}
.mad-dg-dropdown-item:hover { background: var(--mad-bg-muted); }
.mad-dg-dropdown-danger { color: var(--mad-danger); }
.mad-dg-dropdown-danger:hover { background: color-mix(in srgb, var(--mad-danger) 8%, transparent); }

/* ── Inline editing ──────────────────────────────────────────────── */
.mad-dg-cell-input {
  width: 100%;
  min-width: 80px;
  font-size: 0.84rem;
  padding: 2px 6px;
  height: 28px;
}
[x-show].mad-dg-cell-display:hover {
  text-decoration: underline dotted;
  cursor: text;
}

/* Modo click: botão lápis */
.mad-dg-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-sm, 4px);
  color: var(--mad-muted-fg);
  cursor: pointer;
  padding: 2px;
  width: 24px;
  height: 24px;
  opacity: 0.5;            /* visivel mas discreto — antes era 0 (so no hover) */
  transition: opacity .15s, color .15s, border-color .15s;
}
.mad-dg-edit-click:hover .mad-dg-edit-btn,
.mad-dg-edit-btn:focus,
.mad-dg-edit-btn:hover {
  opacity: 1;
}
.mad-dg-edit-btn:hover {
  color: var(--mad-primary);
  border-color: var(--mad-primary);
}

/* Modo inline: inputs sempre visíveis */
.mad-dg-inline-input {
  width: 100%;
  min-width: 80px;
  font-size: 0.84rem;
  padding: 2px 6px;
  height: 28px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--mad-radius-sm, 4px);
  transition: border-color .15s, background .15s;
}
.mad-dg-inline-input:hover {
  border-color: var(--mad-border);
  background: var(--mad-bg);
}
.mad-dg-inline-input:focus {
  border-color: var(--mad-primary);
  background: var(--mad-bg);
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--mad-primary) 20%, transparent);
}
textarea.mad-dg-inline-input {
  height: auto;
  resize: vertical;
}

/* Quando o <select> foi convertido pelo TomSelect, neutraliza a borda/hover/focus
   do select original — o wrapper .ts-control e quem recebe estilo. Sem isso,
   aparece uma borda dupla no hover (a externa do select + a interna do TS). */
.ts-wrapper > select.mad-dg-inline-input,
select.tomselected.mad-dg-inline-input,
select.mad-dg-inline-input.ts-hidden-accessible {
  display: none !important;
}
.ts-wrapper.mad-dg-inline-input,
.ts-wrapper.mad-dg-inline-input:hover,
.ts-wrapper.mad-dg-inline-input:focus {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  height: auto !important;
}
/* Compactar o .ts-control dentro de uma celula da grade — hoje usa o padding
   global (6px 8px) que fica grande pro contexto do grid. */
.mad-dg-cell .ts-control,
.mad-dg-edit-inline .ts-control {
  padding: 3px 8px !important;
  min-height: 28px !important;
  font-size: 0.84rem !important;
}

/* Prefixo (R$) dentro de célula editável */
.mad-dg-edit-prefix {
  font-size: 0.78rem;
  color: var(--mad-muted-fg);
  white-space: nowrap;
  user-select: none;
}

/* ── Tfoot (totals) ──────────────────────────────────────────────── */
.mad-dg-foot {
  background: var(--mad-bg-muted);
  border-top: 2px solid var(--mad-border-strong);
}
.mad-dg-total-cell {
  font-weight: 600;
}

/* ── Footer ──────────────────────────────────────────────────────── */
.mad-dg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 14px;
  border-top: 1px solid var(--mad-border);
  background: var(--mad-bg-subtle);
  flex-wrap: wrap;
  gap: 8px;
}
.mad-dg-per-page {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 16px;
}
.mad-dg-footer .mad-pagination {
  margin-left: auto;
}
.mad-dg-per-page-label {
  font-size: 0.8rem;
  color: var(--mad-text-muted);
  white-space: nowrap;
}
.mad-select-sm {
  font-size: 0.8rem;
  height: 28px;
  padding: 2px 8px;
}
.mad-dg-pagination {
  margin-left: auto;
}


/* ═══════════════════════════════════════════════════════════════════════════
   COMPONENTE — FIELD LIST  (mad-fl-*)
   Componente de lista de campos editáveis (master-detail) com div layout,
   CSS Grid responsivo e Alpine.js para reatividade.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Container raiz ─────────────────────────────────────────────────────── */
.mad-fl {
  display: flex;
  flex-direction: column;
  border-radius: var(--mad-radius);
  overflow: visible;
}

.mad-fl-has-error .mad-fl-header,
.mad-fl-has-error .mad-fl-body .mad-fl-row:last-child,
.mad-fl-has-error .mad-fl-totals,
.mad-fl-has-error .mad-fl-add-row {
  border-color: var(--mad-danger);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.mad-fl-header {
  display: grid;
  gap: var(--mad-s2);
  align-items: center;
  padding: var(--mad-s1) var(--mad-s2);
  background: var(--mad-bg-muted);
  border: 1px solid var(--mad-border);
  border-bottom: none;
  border-radius: var(--mad-radius) var(--mad-radius) 0 0;
}

.mad-fl-header-cell {
  font-size: 11px;
  font-weight: 700;
  color: var(--mad-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Body ────────────────────────────────────────────────────────────────── */
.mad-fl-body {
  display: flex;
  flex-direction: column;
}

/* ── Linhas ──────────────────────────────────────────────────────────────── */
.mad-fl-row {
  display: grid;
  gap: var(--mad-s2);
  align-items: center;
  padding: var(--mad-s1) var(--mad-s2);
  border: 1px solid var(--mad-border);
  border-top: none;
  background: var(--mad-bg);
  transition: background var(--mad-t);
}

.mad-fl-body .mad-fl-row:last-child {
  border-radius: 0 0 var(--mad-radius) var(--mad-radius);
}

/* Quando seguido de totais ou add-row, não arredonda */
.mad-fl-body:has(+ .mad-fl-totals) .mad-fl-row:last-child,
.mad-fl-body:has(+ .mad-fl-add-row) .mad-fl-row:last-child {
  border-radius: 0;
}

.mad-fl-row:hover {
  background: var(--mad-bg-subtle);
}

/* ── Células ─────────────────────────────────────────────────────────────── */
.mad-fl-cell {
  min-width: 0;
}

.mad-fl-cell .mad-input,
.mad-fl-cell select.mad-input,
.mad-fl-cell textarea.mad-input {
  width: 100%;
  box-sizing: border-box;
}

/* ── Money field no field-list ───────────────────────────────────────────── */
.mad-fl-money {
  display: flex;
  align-items: center;
  width: 100%;
}
.mad-fl-money .mad-input {
  text-align: right;
  flex: 1;
  min-width: 0;
}
.mad-fl-money-prefix {
  font-size: var(--mad-text-xs, 0.75rem);
  color: var(--mad-text-muted);
  margin-right: 4px;
  white-space: nowrap;
  user-select: none;
}

/* ── Discount field com toggle %/R$ ────────────────────────────────────── */
.mad-fl-discount {
  display: flex;
  align-items: stretch;
  width: 100%;
}
.mad-fl-discount .mad-input {
  text-align: right;
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}
.mad-fl-discount .mad-input:focus {
  z-index: 1;
  border-right: 1px solid var(--mad-accent);
}
.mad-fl-discount-type {
  border: 1px solid var(--mad-border);
  background: var(--mad-bg-muted);
  color: var(--mad-text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  cursor: pointer;
  border-radius: 0 var(--mad-radius-sm) var(--mad-radius-sm) 0;
  outline: none;
  min-width: 38px;
  text-align: center;
  transition: border-color var(--mad-t), color var(--mad-t);
  -webkit-appearance: none;
  appearance: none;
}
.mad-fl-discount-type:focus {
  border-color: var(--mad-accent);
  color: var(--mad-text);
}
.mad-fl-discount-type:hover {
  color: var(--mad-text);
  background: var(--mad-bg-subtle);
}

/* ── File / Multifile ────────────────────────────────────────────────────── */
.mad-fl-file {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 28px;
}
.mad-fl-file-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--mad-bg-muted);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-sm);
  padding: 2px 6px;
  font-size: 11px;
  max-width: 180px;
}
.mad-fl-file-tag-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}
.mad-fl-file-tag-x {
  background: none;
  border: none;
  padding: 0 1px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--mad-text-muted);
}
.mad-fl-file-tag-x:hover {
  color: var(--mad-danger);
}
.mad-fl-file-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px dashed var(--mad-border);
  border-radius: var(--mad-radius-sm);
  background: none;
  cursor: pointer;
  color: var(--mad-text-muted);
  transition: all .15s;
}
.mad-fl-file-pick:hover {
  border-color: var(--mad-primary);
  color: var(--mad-primary);
  background: var(--mad-bg-muted);
}
.mad-fl-file-pick:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── Date (dentro de field-list) ─────────────────────────────────────────── */
.mad-fl-date {
  display: flex;
  align-items: stretch;
  width: 100%;
}
.mad-fl-date .mad-input {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}
.mad-fl-date-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 1px solid var(--mad-border);
  border-radius: 0 var(--mad-radius-sm) var(--mad-radius-sm) 0;
  background: var(--mad-bg-muted);
  color: var(--mad-text-muted);
  cursor: pointer;
  transition: all .15s;
}
.mad-fl-date-btn:hover:not(:disabled) {
  color: var(--mad-primary);
  background: var(--mad-bg-subtle);
}
.mad-fl-date-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── Radio group inline (dentro de field-list) ──────────────────────────── */
.mad-fl-radio-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}
.mad-fl-radio-group .mad-radio-wrap { gap: 4px; }
.mad-fl-radio-group .mad-radio-label { font-size: 12px; }

/* ── Coluna de ações ─────────────────────────────────────────────────────── */
.mad-fl-actions-header,
.mad-fl-actions-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Botão remover ───────────────────────────────────────────────────────── */
.mad-fl-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--mad-radius-sm);
  background: transparent;
  color: var(--mad-text-subtle);
  cursor: pointer;
  transition: background var(--mad-t), color var(--mad-t), border-color var(--mad-t);
  flex-shrink: 0;
}

.mad-fl-remove-btn:hover {
  background: var(--mad-danger-subtle);
  color: var(--mad-danger);
  border-color: color-mix(in srgb, var(--mad-danger) 20%, transparent);
}

/* ── Botoes de acao customizada (<mad-field-list-action>) ────────────────── */
/* Coluna que agrupa varios botoes de acao — lado a lado                      */
.mad-fl-actions-cell {
  gap: 2px;
  padding: 0 4px;
}

.mad-fl-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--mad-radius-sm);
  background: transparent;
  color: var(--mad-text-subtle);
  cursor: pointer;
  transition: background var(--mad-t), color var(--mad-t), border-color var(--mad-t);
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1;
}

/* Estado base — variants colorem o icone de cara (consistente com color= livre) */
.mad-fl-action-btn.mad-fl-action-danger  { color: var(--mad-danger); }
.mad-fl-action-btn.mad-fl-action-primary { color: var(--mad-primary); }
.mad-fl-action-btn.mad-fl-action-success { color: var(--mad-success); }
.mad-fl-action-btn.mad-fl-action-warning { color: var(--mad-warning); }
.mad-fl-action-btn.mad-fl-action-info    { color: var(--mad-info); }
.mad-fl-action-btn.mad-fl-action-ghost   { color: var(--mad-text-muted); }

/* Hover neutro — so aplica bg/border quando nao ha variant */
.mad-fl-action-btn:hover {
  background: var(--mad-bg-subtle);
  border-color: var(--mad-border);
}

/* Hover dos variants — bg suave + borda derivada (cor do icone ja vem do base) */
.mad-fl-action-btn.mad-fl-action-danger:hover {
  background: var(--mad-danger-subtle);
  border-color: color-mix(in srgb, var(--mad-danger) 20%, transparent);
}

.mad-fl-action-btn.mad-fl-action-primary:hover {
  background: var(--mad-primary-subtle);
  border-color: color-mix(in srgb, var(--mad-primary) 20%, transparent);
}

.mad-fl-action-btn.mad-fl-action-success:hover {
  background: var(--mad-success-subtle);
  border-color: color-mix(in srgb, var(--mad-success) 20%, transparent);
}

.mad-fl-action-btn.mad-fl-action-warning:hover {
  background: var(--mad-warning-subtle);
  border-color: color-mix(in srgb, var(--mad-warning) 20%, transparent);
}

.mad-fl-action-btn.mad-fl-action-info:hover {
  background: var(--mad-info-subtle);
  border-color: color-mix(in srgb, var(--mad-info) 20%, transparent);
}

/* color="#hex" livre: hover derivado do currentColor */
.mad-fl-action-btn[style*="color:"]:hover {
  background: color-mix(in srgb, currentColor 10%, transparent);
  border-color: color-mix(in srgb, currentColor 25%, transparent);
}

.mad-fl-action-btn .mad-fl-action-btn-label {
  margin-left: 4px;
  font-size: 11px;
  font-weight: 500;
}

/* Quando botao tem label, cresce alem do quadrado fixo */
.mad-fl-action-btn:has(.mad-fl-action-btn-label) {
  width: auto;
  min-width: 28px;
}

/* ── Drag handle ─────────────────────────────────────────────────────────── */
.mad-fl-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mad-text-subtle);
  cursor: grab;
  border-radius: var(--mad-radius-sm);
  transition: color var(--mad-t);
  user-select: none;
}

.mad-fl-handle:hover {
  color: var(--mad-text-muted);
}

.mad-fl-handle:active {
  cursor: grabbing;
}

/* ── Sortable.js states ──────────────────────────────────────────────────── */
.mad-fl-ghost {
  opacity: 0.4;
  background: var(--mad-accent-subtle) !important;
  border-color: var(--mad-accent-border) !important;
}

.mad-fl-chosen {
  box-shadow: var(--mad-shadow-md);
  z-index: 10;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.mad-fl-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--mad-s2);
  padding: var(--mad-s6) var(--mad-s4);
  border: 1px dashed var(--mad-border);
  border-radius: var(--mad-radius);
  color: var(--mad-text-subtle);
  font-size: var(--mad-text-sm);
}

/* ── Linha de totais ─────────────────────────────────────────────────────── */
.mad-fl-totals {
  display: grid;
  gap: var(--mad-s2);
  align-items: center;
  padding: var(--mad-s1) var(--mad-s2);
  background: var(--mad-bg-subtle);
  border: 1px solid var(--mad-border);
  border-top: none;
  border-radius: 0 0 var(--mad-radius) var(--mad-radius);
}

.mad-fl-totals:has(+ .mad-fl-add-row) {
  border-radius: 0;
}

.mad-fl-total-cell {
  font-weight: 700;
  font-size: var(--mad-text-sm);
  color: var(--mad-text);
  text-align: right;
}

/* ── Botão adicionar linha ───────────────────────────────────────────────── */
.mad-fl-add-row {
  display: flex;
  align-items: center;
  padding: var(--mad-s2) 0;
  gap: var(--mad-s2);
}

.mad-fl-add-btn {
  color: var(--mad-text-muted);
  gap: var(--mad-s1);
}

.mad-fl-add-btn:not(:disabled):hover {
  color: var(--mad-text);
}

.mad-fl-add-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Mobile: layout em cards (≤640px) ────────────────────────────────────── */
@media (max-width: 640px) {
  /* Oculta header desktop */
  .mad-fl-header { display: none; }

  /* Cada linha vira um card */
  .mad-fl-row {
    display: flex !important;
    flex-direction: column;
    gap: var(--mad-s3);
    padding: var(--mad-s3);
    border: 1px solid var(--mad-border) !important;
    border-top: none !important;
    border-radius: 0 !important;
  }

  .mad-fl-body .mad-fl-row:first-child {
    border-top: 1px solid var(--mad-border) !important;
    border-radius: var(--mad-radius) var(--mad-radius) 0 0 !important;
  }

  /* Mostra data-label como etiqueta inline acima do input */
  .mad-fl-cell::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--mad-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 3px;
  }

  /* Ações ficam à direita no topo do card */
  .mad-fl-actions-cell {
    position: absolute;
    top: var(--mad-s2);
    right: var(--mad-s2);
  }

  .mad-fl-row { position: relative; }

  /* Totais empilham */
  .mad-fl-totals {
    display: flex !important;
    flex-direction: column;
    gap: var(--mad-s1);
  }

  /* Handle oculto no mobile (sem drag) */
  .mad-fl-handle { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════
   DB SEEK FIELD (MadSeek)
   ═══════════════════════════════════════════════════════════════════ */
.mad-dbseek-field .mad-input-group {
  position: relative;
}

.mad-dbseek-display {
  padding-right: 80px !important;
  cursor: pointer;
  background: var(--mad-bg) !important;
}

.mad-seek-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  height: 38px;
  border: 1px solid var(--mad-border);
  border-left: none;
  background: var(--mad-bg);
  color: var(--mad-muted);
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
.mad-seek-clear-btn:hover:not(:disabled) {
  background: var(--mad-danger, #dc3545);
  color: #fff;
  border-color: var(--mad-danger, #dc3545);
}
.mad-seek-clear-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.mad-seek-clear-btn svg {
  width: 14px;
  height: 14px;
}

/* Border-radius do input e botões */
.mad-dbseek-field .mad-dbseek-display {
  border-radius: var(--mad-radius-md) 0 0 var(--mad-radius-md);
}
.mad-seek-clear-btn {
  border-radius: 0 var(--mad-radius-md) var(--mad-radius-md) 0;
}

/* Modal do seek: z-index alto para ficar sobre outros modals */
.mad-dbseek-field .mad-modal-overlay {
  z-index: 1060;
}
.mad-dbseek-field .mad-modal-body {
  padding: var(--mad-s3);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Detail Form (.mad-df) — sub-formulário detalhe com listagem
   ═══════════════════════════════════════════════════════════════════════════ */

.mad-df { position: relative; }

.mad-df-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.mad-df-form-inline {
  padding: 16px;
  margin-bottom: 12px;
}

.mad-df-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--mad-border);
}

.mad-df-list { margin-top: 0; }

.mad-df-row-editing {
  background: color-mix(in srgb, var(--mad-primary) 6%, transparent) !important;
}

/* Ação primary (azul) */
.mad-dg-action-primary {
  color: var(--mad-primary);
  border-color: var(--mad-primary);
}
.mad-dg-action-primary:hover {
  background: color-mix(in srgb, var(--mad-primary) 10%, transparent);
}

/* ═══════════════════════════════════════════════════════════════════
   DATAGRID — CARD VIEW MODE
   ═══════════════════════════════════════════════════════════════════ */

/* ── View toggle (segmented control) ───────────────────────────── */
.mad-dg-view-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius);
  overflow: hidden;
  background: var(--mad-bg);
}
.mad-dg-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 10px;
  color: var(--mad-text-subtle);
  transition: background var(--mad-t), color var(--mad-t);
  line-height: 1;
}
.mad-dg-view-btn:hover {
  color: var(--mad-text);
  background: var(--mad-bg-muted);
}
.mad-dg-view-btn.active {
  color: var(--mad-text);
  background: var(--mad-bg-muted);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}
.mad-dg-view-btn + .mad-dg-view-btn {
  border-left: 1px solid var(--mad-border);
}

/* ── Cards container ───────────────────────────────────────────── */
.mad-dg-cards-wrap {
  padding: 12px 16px 16px;
}
.mad-dg-cards {
  display: grid;
  grid-template-columns: repeat(var(--mad-dg-card-cols, 3), 1fr);
  gap: 14px;
}
@media (max-width: 1200px) {
  .mad-dg-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 768px) {
  .mad-dg-cards {
    grid-template-columns: 1fr;
  }
}
@media (min-width: 1600px) {
  .mad-dg-cards:not([style*="--mad-dg-card-cols"]) {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ── Individual card ───────────────────────────────────────────── */
.mad-dg-card {
  display: flex;
  flex-direction: column;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-lg);
  transition: box-shadow var(--mad-t), border-color var(--mad-t), transform var(--mad-t);
}
.mad-dg-card:hover {
  border-color: var(--mad-border-strong);
  box-shadow: var(--mad-shadow-md);
  transform: translateY(-1px);
}

/* ── Card image ────────────────────────────────────────────────── */
.mad-dg-card-image {
  width: 100%;
  height: 160px;
  overflow: hidden;
  border-bottom: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-lg) var(--mad-radius-lg) 0 0;
  background: var(--mad-bg-muted);
}
.mad-dg-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s ease;
}
.mad-dg-card:hover .mad-dg-card-image img {
  transform: scale(1.03);
}

/* ── Card body ─────────────────────────────────────────────────── */
.mad-dg-card-body {
  flex: 1;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Card header (title + badge) ───────────────────────────────── */
.mad-dg-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.mad-dg-card-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.mad-dg-card-title {
  font-size: var(--mad-text-base);
  font-weight: 600;
  color: var(--mad-text);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.mad-dg-card-subtitle {
  font-size: var(--mad-text-xs);
  color: var(--mad-text-muted);
  letter-spacing: .01em;
}

/* ── Card highlight (money / prominent value) ──────────────────── */
.mad-dg-card-highlight {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--mad-text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

/* ── Card fields (label: value list) ───────────────────────────── */
.mad-dg-card-fields {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  padding-top: 12px;
  border-top: 1px solid var(--mad-border);
  align-items: baseline;
}
.mad-dg-card-field {
  display: flex;
  align-items: baseline;
  gap: 10px;
  grid-column: 1 / -1;
  font-size: var(--mad-text-sm);
}
@supports (grid-template-columns: subgrid) {
  .mad-dg-card-field {
    display: grid;
    grid-template-columns: subgrid;
  }
}
.mad-dg-card-field-label {
  color: var(--mad-text-subtle);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  line-height: 1.85;
}
.mad-dg-card-field-value {
  color: var(--mad-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  line-height: 1.85;
}

/* ── Card footer (actions bar) ─────────────────────────────────── */
.mad-dg-card-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--mad-border);
  background: var(--mad-bg-subtle);
  border-radius: 0 0 var(--mad-radius-lg) var(--mad-radius-lg);
}
.mad-dg-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.mad-dg-card-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius);
  cursor: pointer;
  padding: 5px 10px;
  color: var(--mad-text-muted);
  font-size: var(--mad-text-xs);
  font-weight: 500;
  transition: background var(--mad-t), color var(--mad-t), border-color var(--mad-t);
  white-space: nowrap;
  line-height: 1;
}
.mad-dg-card-action:hover {
  background: var(--mad-bg-muted);
  color: var(--mad-text);
  border-color: var(--mad-border-strong);
}
.mad-dg-card-action:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.mad-dg-card-action-danger {
  color: var(--mad-danger);
  border-color: color-mix(in srgb, var(--mad-danger) 25%, transparent);
}
.mad-dg-card-action-danger:hover {
  background: color-mix(in srgb, var(--mad-danger) 6%, transparent);
  color: var(--mad-danger);
}

/* ── Card highlight animation (manageRow) ──────────────────────── */
.mad-dg-card-highlight-anim {
  animation: mad-card-flash 2.5s ease-out forwards;
}
@keyframes mad-card-flash {
  0%   { box-shadow: 0 0 0 3px color-mix(in srgb, var(--mad-info) 40%, transparent); }
  70%  { box-shadow: 0 0 0 3px color-mix(in srgb, var(--mad-info) 10%, transparent); }
  100% { box-shadow: none; }
}

/* Popover de confirmação de remoção */
.mad-df-delete-wrap {
  position: relative;
  display: inline-flex;
}
.mad-df-delete-popover {
  position: fixed;
  z-index: 9999;
  min-width: 180px;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius, 8px);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: 12px;
}
.mad-df-delete-msg {
  font-size: 0.84rem;
  color: var(--mad-text, #18181b);
  margin: 0 0 10px;
  line-height: 1.4;
}
.mad-df-delete-btns {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ── Confirm Modal ─────────────────────────────────────────────── */
.mad-confirm-overlay {
  position: fixed; inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 150ms ease;
}
.mad-confirm-overlay.mad-confirm-visible { opacity: 1; }
.mad-confirm-modal {
  background: var(--mad-bg, #fff);
  color: var(--mad-text, #1f2937);
  border-radius: var(--mad-radius, 8px);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  padding: 24px 28px;
  min-width: 320px; max-width: 440px;
  text-align: center;
  transform: scale(.95); transition: transform 150ms ease;
}
.mad-confirm-visible .mad-confirm-modal { transform: scale(1); }
.mad-confirm-icon {
  margin-bottom: 12px; color: var(--mad-primary, #3b82f6);
}
.mad-confirm-icon svg { width: 36px; height: 36px; }
.mad-confirm-icon-danger { color: var(--mad-danger, #ef4444); }
.mad-confirm-message {
  font-size: 0.95rem; line-height: 1.5;
  color: var(--mad-text, #18181b);
  margin-bottom: 20px;
}
.mad-confirm-btns {
  display: flex; gap: 8px; justify-content: center;
}

/* ── Confirm Popover ──────────────────────────────────────────── */
.mad-confirm-popover {
  position: fixed; z-index: 10000;
  min-width: 200px;
  background: var(--mad-bg, #fff);
  border: 1px solid var(--mad-border, #e5e7eb);
  border-radius: var(--mad-radius, 8px);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: 12px 14px;
  opacity: 0; transform: translateY(-4px);
  transition: opacity 150ms ease, transform 150ms ease;
}
.mad-confirm-popover.mad-confirm-popover-visible {
  opacity: 1; transform: translateY(0);
}
.mad-confirm-popover-msg {
  font-size: 0.84rem; color: var(--mad-text, #18181b);
  margin: 0 0 10px; line-height: 1.4;
}
.mad-confirm-popover-btns {
  display: flex; gap: 6px; justify-content: flex-end;
}

/* ── MadDialog (MadMessage.info/error/warning/confirm) ─────────── */
.mad-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  /* z-index aplicado inline pelo JS (stack dinamico) */
}
.mad-dialog-box {
  background: var(--mad-bg, #fff);
  color: var(--mad-text, #374151);
  border-radius: 10px;
  padding: 28px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  font-family: inherit;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.mad-dialog-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.mad-dialog-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  /* cor aplicada inline pelo JS (depende do tipo) */
}
.mad-dialog-title {
  font-size: 16px;
}
.mad-dialog-body {
  font-size: 14px;
  color: var(--mad-text, #374151);
  line-height: 1.6;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.mad-dialog-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Mad loader (Mad.wait / Aguarde...) ───────────────────────── */
#mad-loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.25);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
}
#mad-loader-overlay.mad-loader-visible {
  display: flex;
}
.mad-loader-box {
  background: #111;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.mad-loader-spinner {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
}

.mad-df-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
}
.mad-df-page-info {
  font-size: 0.84rem;
  color: var(--mad-muted-fg);
}


/* ═══════════════════════════════════════════════════════════════════
   33. COMPONENTE — FULL CALENDAR
   ═══════════════════════════════════════════════════════════════════ */

.mad-fc-wrap {
  width: 100%;
}
.mad-fc-wrap .fc {
  font-family: inherit;
  --fc-border-color: var(--mad-border, #e5e7eb);
}
.mad-fc-wrap .fc-scrollgrid,
.mad-fc-wrap .fc-scrollgrid table {
  border-color: var(--mad-border, #e5e7eb);
}
.mad-fc-wrap .fc-scrollgrid td,
.mad-fc-wrap .fc-scrollgrid th,
.mad-fc-wrap .fc-daygrid-day,
.mad-fc-wrap .fc-timegrid-slot,
.mad-fc-wrap .fc-timegrid-col,
.mad-fc-wrap .fc-list-table td {
  border-color: var(--mad-border, #e5e7eb);
}
.mad-fc-wrap .fc-toolbar-title {
  font-size: 1.15rem !important;
  font-weight: 600;
}
.mad-fc-wrap .fc-button {
  font-size: 0.8rem;
  padding: 4px 10px;
}
.mad-fc-wrap .fc-button-primary {
  background-color: var(--mad-primary, #3b82f6);
  border-color: var(--mad-primary, #3b82f6);
}
.mad-fc-wrap .fc-button-primary:not(:disabled).fc-button-active,
.mad-fc-wrap .fc-button-primary:not(:disabled):active {
  background-color: var(--mad-primary-hover, #2563eb);
  border-color: var(--mad-primary-hover, #2563eb);
}
.mad-fc-wrap .fc-daygrid-event {
  border-radius: var(--mad-radius-sm, 4px);
  padding: 1px 4px;
  font-size: 0.82rem;
}
.mad-fc-wrap .fc-timegrid-event {
  border-radius: var(--mad-radius-sm, 4px);
  font-size: 0.82rem;
}
.mad-fc-wrap .fc-day-today {
  background: var(--mad-primary-bg, rgba(59, 130, 246, 0.06)) !important;
}
.mad-fc-wrap .fc-col-header-cell {
  font-size: 0.82rem;
  font-weight: 500;
  text-transform: capitalize;
}


/* ═══════════════════════════════════════════════════════════════════
   34. COMPONENTE — RESOURCE TIMELINE (vertical grid)
   Eixo Y = horas, Eixo X = dia × recurso
   ═══════════════════════════════════════════════════════════════════ */

.mad-rt {
  --mad-rt-border: 1px solid var(--mad-border, #e5e7eb);
  --mad-rt-slot-h: 56px;
  width: 100%;
  font-size: 0.84rem;
}

/* ── Toolbar ─────────────────────────────────────────────────── */
.mad-rt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.mad-rt-toolbar-nav { display: flex; gap: 4px; align-items: center; }
.mad-rt-toolbar-title { font-size: 1.1rem; font-weight: 600; text-align: center; flex: 1; }
.mad-rt-toolbar-views { display: flex; gap: 2px; }

.mad-rt-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 5px 12px;
  border: var(--mad-rt-border);
  border-radius: var(--mad-radius, 6px);
  background: var(--mad-bg, #fff);
  color: var(--mad-text, #1f2937);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}
.mad-rt-btn:hover { background: var(--mad-bg-muted, #f3f4f6); }
.mad-rt-btn-active {
  background: var(--mad-primary, #3b82f6) !important;
  color: #fff !important;
  border-color: var(--mad-primary, #3b82f6);
}

/* ── Scroll container ────────────────────────────────────────── */
.mad-rt-scroll {
  overflow-x: auto;
  border: var(--mad-rt-border);
  border-radius: var(--mad-radius, 6px);
}

/* ── CSS Grid ────────────────────────────────────────────────── */
.mad-rt-grid {
  display: grid;
  min-width: fit-content;
}

/* ── Header: corner cells ────────────────────────────────────── */
.mad-rt-corner {
  position: sticky;
  left: 0;
  z-index: 4;
  background: var(--mad-bg-muted, #f9fafb);
  border-right: var(--mad-rt-border);
  border-bottom: var(--mad-rt-border);
}
.mad-rt-corner-top { grid-row: 1; grid-column: 1; }
.mad-rt-corner-bot { grid-row: 2; grid-column: 1; }

/* ── Header: day row ─────────────────────────────────────────── */
.mad-rt-day-header {
  grid-row: 1;
  background: var(--mad-bg-muted, #f9fafb);
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 4px;
  border-bottom: var(--mad-rt-border);
  border-right: var(--mad-rt-border);
}

/* ── Header: resource row ────────────────────────────────────── */
.mad-rt-res-header {
  grid-row: 2;
  background: var(--mad-bg-muted, #f9fafb);
  text-align: center;
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--mad-text-subtle, #6b7280);
  padding: 5px 4px;
  border-bottom: var(--mad-rt-border);
  border-right: var(--mad-rt-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Time label (left column) ────────────────────────────────── */
.mad-rt-time {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--mad-bg, #fff);
  border-right: var(--mad-rt-border);
  border-bottom: var(--mad-rt-border);
  padding: 0 8px;
  font-size: 0.78rem;
  color: var(--mad-text-subtle, #6b7280);
  font-weight: 500;
  text-align: right;
  min-height: var(--mad-rt-slot-h);
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
  width: 60px;
  min-width: 60px;
}

/* ── Grid cell (time × resource) ─────────────────────────────── */
.mad-rt-cell {
  position: relative;
  border-right: var(--mad-rt-border);
  border-bottom: var(--mad-rt-border);
  min-height: var(--mad-rt-slot-h);
  cursor: pointer;
  transition: background 0.1s;
}
.mad-rt-cell:hover {
  background: var(--mad-bg-muted, #f9fafb);
}

/* Today column highlight */
.mad-rt-today { background: var(--mad-primary-bg, rgba(59, 130, 246, 0.06)) !important; }
.mad-rt-today-col { background: rgba(254, 243, 199, 0.35); }

/* ── Event block (vertical position) ─────────────────────────── */
.mad-rt-event {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: var(--mad-radius-sm, 4px);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 500;
  padding: 3px 5px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
  z-index: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.mad-rt-event:hover {
  opacity: 0.92;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
  z-index: 2;
}
.mad-rt-event-time {
  font-size: 0.68rem;
  opacity: 0.85;
}
.mad-rt-event-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════
   KANBAN BOARD
   ═══════════════════════════════════════════════════════════════════ */

/* ── Board ── */
.mad-kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  min-height: 500px;
  max-height: calc(100vh - 220px);
}

/* ── Column ── */
.mad-kanban-col {
  width: 320px;
  min-width: 320px;
  flex: none;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid var(--mad-border, #e5e7eb);
  background: var(--mad-bg-subtle, #fafafa);
  max-height: 100%;
}
.mad-kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px 12px 0 0;
}
.mad-kanban-col-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mad-kanban-col-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--mad-text, #18181b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mad-kanban-col-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid #e4e4e7;
  background: #f4f4f5;
  color: #52525b;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.mad-kanban-col-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #a1a1aa;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.mad-kanban-col-add:hover {
  background: #e4e4e7;
  color: #52525b;
}
.mad-kanban-col-add svg { width: 14px; height: 14px; }
.mad-kanban-col-summary {
  padding: 0 12px 6px;
  font-size: 12px;
  color: #71717a;
  font-variant-numeric: tabular-nums;
}

/* ── Cards container ── */
.mad-kanban-cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding: 8px;
  min-height: 120px;
  transition: background .15s;
}
.mad-kanban-col--drag-over > .mad-kanban-cards {
  background: rgba(99,102,241,.04);
}

/* ── Card ── */
.mad-kanban-card {
  position: relative;
  border-radius: 8px;
  border: 1px solid var(--mad-border, #e5e7eb);
  background: #fff;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  cursor: pointer;
  transition: box-shadow .15s, transform .08s;
}
.mad-kanban-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.mad-kanban-card--dragging {
  opacity: 0.4;
}

/* Highlight animation (after manageCard) */
@keyframes mad-kanban-highlight {
  0%   { background: rgba(59,130,246,.12); }
  100% { background: #fff; }
}
.mad-kanban-card--highlight {
  animation: mad-kanban-highlight 2s ease-out;
}

/* ── Card: hover actions ── */
.mad-kanban-card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s;
}
.mad-kanban-card:hover .mad-kanban-card-actions {
  opacity: 1;
}
.mad-kanban-card-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: #d4d4d8;
  cursor: pointer;
}
.mad-kanban-card-menu-btn:hover {
  background: #f4f4f5;
  color: #52525b;
}
.mad-kanban-card-menu-btn svg { width: 14px; height: 14px; }
.mad-kanban-card-grip {
  cursor: grab;
  padding: 2px;
  border-radius: 4px;
  color: #d4d4d8;
}
.mad-kanban-card-grip:hover { color: #71717a; }
.mad-kanban-card-grip:active { cursor: grabbing; }
.mad-kanban-card-grip svg { width: 14px; height: 14px; }

/* ── Card: badges ── */
.mad-kanban-card-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}
.mad-kanban-badge {
  display: inline-flex;
  align-items: center;
  height: 16px;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.mad-kanban-badge--muted {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 500;
  color: #71717a;
  background: none;
  padding: 0;
  font-variant-numeric: tabular-nums;
}

/* ── Card: content ── */
.mad-kanban-card-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--mad-text, #18181b);
  margin-bottom: 4px;
}
.mad-kanban-card-subtitle {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 10px;
  font-style: italic;
  color: #a1a1aa;
  margin-bottom: 6px;
}

/* ── Card: meta rows (contact, seller, etc) ── */
.mad-kanban-card-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}
.mad-kanban-card-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.mad-kanban-card-meta-row svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: #a1a1aa;
}
.mad-kanban-card-meta-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  color: #52525b;
}
.mad-kanban-card-meta-sub {
  padding-left: 18px;
  font-size: 10px;
  color: #a1a1aa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Card: footer ── */
.mad-kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #f4f4f5;
  padding-top: 8px;
  margin-top: 6px;
}
.mad-kanban-card-value {
  font-size: 12px;
  font-weight: 600;
  color: #16a34a;
  font-variant-numeric: tabular-nums;
}
.mad-kanban-card-date {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #a1a1aa;
}
.mad-kanban-card-date svg { width: 10px; height: 10px; }

/* ── Drag & drop indicator ── */
.mad-kanban-drop-indicator {
  height: 3px;
  background: #818cf8;
  border-radius: 2px;
  margin: 0 4px;
  flex-shrink: 0;
}

/* ── Loading spinner (load more) ── */
.mad-kanban-loading {
  text-align: center;
  padding: 8px;
  font-size: 12px;
  color: #a1a1aa;
}

/* ═══════════════════════════════════════════════════════════════════════════
   STEPS — mad-steps-* / mad-step-*
   Variants: arrows, dots, numbers, progress
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Base container ── */
.mad-steps {
  display: flex;
  align-items: flex-start;
  gap: 0;
  width: 100%;
  position: relative;
  font-family: inherit;
}

/* ── Size modifiers ── */
.mad-steps--sm .mad-step-circle { width: 24px; height: 24px; font-size: 11px; }
.mad-steps--sm .mad-step-label { font-size: 12px; }
.mad-steps--sm .mad-step-desc { font-size: 11px; }

.mad-steps--lg .mad-step-circle { width: 40px; height: 40px; font-size: 16px; }
.mad-steps--lg .mad-step-label { font-size: 15px; }
.mad-steps--lg .mad-step-desc { font-size: 13px; }

/* ── Individual step ── */
.mad-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
  text-align: center;
  min-width: 0;
}

/* ── Circle indicator ── */
.mad-step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  transition: background .25s, color .25s, border-color .25s, box-shadow .25s;
  border: 2px solid var(--mad-border, #e4e4e7);
  background: var(--mad-bg-muted, #f4f4f5);
  color: var(--mad-text-muted, #71717a);
  position: relative;
  z-index: 2;
}
.mad-step-circle svg { width: 16px; height: 16px; }

/* ── Step states ── */
.mad-step--completed .mad-step-circle {
  background: var(--mad-primary, #18181b);
  border-color: var(--mad-primary, #18181b);
  color: #fff;
}
.mad-step--active .mad-step-circle {
  background: var(--mad-primary, #18181b);
  border-color: var(--mad-primary, #18181b);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(24,24,27,.1);
}
.mad-step--pending .mad-step-circle {
  background: var(--mad-bg-muted, #f4f4f5);
  border-color: var(--mad-border, #d4d4d8);
  color: var(--mad-text-muted, #71717a);
}
.mad-step--error .mad-step-circle {
  background: var(--mad-danger, #dc2626);
  border-color: var(--mad-danger, #dc2626);
  color: #fff;
}

/* ── Labels ── */
.mad-step-label {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mad-text, #18181b);
  line-height: 1.3;
}
.mad-step--pending .mad-step-label { color: var(--mad-text-muted, #71717a); }
.mad-step--error .mad-step-label { color: var(--mad-danger, #dc2626); }

.mad-step-desc {
  margin-top: 2px;
  font-size: 12px;
  color: var(--mad-text-muted, #71717a);
  line-height: 1.4;
}

/* ── Connector line (dots / numbers variants) ── */
.mad-steps-connector {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--mad-border, #e4e4e7);
  z-index: 1;
}
.mad-steps--sm .mad-steps-connector { top: 12px; }
.mad-steps--lg .mad-steps-connector { top: 20px; }

.mad-steps-connector-fill {
  height: 100%;
  background: var(--mad-primary, #18181b);
  transition: width .4s ease;
  border-radius: 1px;
}

/* ── Dots variant ── */
.mad-steps--dots .mad-step-circle {
  width: 12px;
  height: 12px;
  border-width: 2px;
  font-size: 0;
}
.mad-steps--dots .mad-step-circle svg { display: none; }
.mad-steps--dots .mad-steps-connector { top: 5px; }
.mad-steps--dots.mad-steps--sm .mad-step-circle { width: 10px; height: 10px; }
.mad-steps--dots.mad-steps--lg .mad-step-circle { width: 16px; height: 16px; }

/* ── Numbers variant ── */
.mad-steps--numbers .mad-step-circle {
  font-variant-numeric: tabular-nums;
}

/* ── Arrows variant ── */
.mad-steps--arrows {
  gap: 0;
}
.mad-steps--arrows .mad-step {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 10px 28px;
  background: var(--mad-bg-muted, #f4f4f5);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%, 14px 50%);
  text-align: left;
  border-radius: 0;
  min-width: 0;
  overflow: hidden;
}
.mad-steps--arrows .mad-step:first-child {
  padding-left: 16px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%);
  border-radius: var(--mad-radius-md, 8px) 0 0 var(--mad-radius-md, 8px);
}
.mad-steps--arrows .mad-step:last-child {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 14px 50%);
  border-radius: 0 var(--mad-radius-md, 8px) var(--mad-radius-md, 8px) 0;
}
.mad-steps--arrows .mad-step--completed,
.mad-steps--arrows .mad-step--active {
  background: var(--mad-primary, #18181b);
  color: #fff;
}
.mad-steps--arrows .mad-step--completed .mad-step-label,
.mad-steps--arrows .mad-step--active .mad-step-label {
  color: #fff;
}
.mad-steps--arrows .mad-step--completed .mad-step-desc,
.mad-steps--arrows .mad-step--active .mad-step-desc {
  color: rgba(255,255,255,.7);
}
.mad-steps--arrows .mad-step--error {
  background: var(--mad-danger, #dc2626);
}
.mad-steps--arrows .mad-step--error .mad-step-label { color: #fff; }
.mad-steps--arrows .mad-step-circle {
  width: 24px; height: 24px;
  border: none;
  background: rgba(255,255,255,.2);
  color: #fff;
  font-size: 12px;
}
.mad-steps--arrows .mad-step--pending .mad-step-circle {
  background: rgba(0,0,0,.08);
  color: var(--mad-text-muted, #71717a);
}
.mad-steps--arrows .mad-step-label { margin-top: 0; }
.mad-steps--arrows .mad-step-desc { margin-top: 0; }
.mad-steps--arrows .mad-step-arrow-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.mad-steps--arrows .mad-steps-connector { display: none; }

/* ── Progress variant ── */
.mad-steps--progress .mad-steps-connector { display: none; }

.mad-steps-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--mad-bg-muted, #f4f4f5);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
}
.mad-steps-progress-fill {
  height: 100%;
  background: var(--mad-primary, #18181b);
  border-radius: 3px;
  transition: width .4s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TIMELINE — mad-tl-*
   ═══════════════════════════════════════════════════════════════════════════ */

.mad-timeline {
  position: relative;
  padding-left: 32px;
}
.mad-timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--mad-border, #e4e4e7);
}

/* ── Both-sides variant ── */
.mad-timeline--both {
  padding-left: 0;
}
.mad-timeline--both::before {
  left: 50%;
  transform: translateX(-50%);
}
.mad-timeline--both .mad-tl-item {
  width: 50%;
}
.mad-timeline--both .mad-tl-item--left {
  padding-right: 40px;
  text-align: right;
}
.mad-timeline--both .mad-tl-item--left .mad-tl-dot {
  left: auto;
  right: -12px;
}
.mad-timeline--both .mad-tl-item--right {
  margin-left: 50%;
  padding-left: 40px;
}
.mad-timeline--both .mad-tl-item--right .mad-tl-dot {
  left: -12px;
}

/* ── Individual item ── */
.mad-tl-item {
  position: relative;
  padding-bottom: 24px;
}
.mad-tl-item:last-child { padding-bottom: 0; }

/* ── Dot indicator ── */
.mad-tl-dot {
  position: absolute;
  left: -32px;
  top: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mad-bg-muted, #f4f4f5);
  border: 2px solid var(--mad-border, #e4e4e7);
  z-index: 2;
}
.mad-tl-dot svg { width: 12px; height: 12px; color: var(--mad-text-muted, #71717a); }

.mad-tl-dot--success {
  background: #dcfce7;
  border-color: #86efac;
}
.mad-tl-dot--success svg { color: #16a34a; }

.mad-tl-dot--info {
  background: #dbeafe;
  border-color: #93c5fd;
}
.mad-tl-dot--info svg { color: #2563eb; }

.mad-tl-dot--warning {
  background: #fef3c7;
  border-color: #fcd34d;
}
.mad-tl-dot--warning svg { color: #d97706; }

.mad-tl-dot--danger {
  background: #fee2e2;
  border-color: #fca5a5;
}
.mad-tl-dot--danger svg { color: #dc2626; }

/* ── Time label ── */
.mad-tl-time {
  font-size: 11px;
  color: var(--mad-text-muted, #71717a);
  margin-bottom: 2px;
}

/* ── Title ── */
.mad-tl-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--mad-text, #18181b);
  line-height: 1.4;
}

/* ── Body / description ── */
.mad-tl-body {
  font-size: 13px;
  color: var(--mad-text-muted, #71717a);
  line-height: 1.5;
  margin-top: 4px;
}

/* ── Embedded card ── */
.mad-tl-card {
  background: var(--mad-bg-muted, #f4f4f5);
  border: 1px solid var(--mad-border, #e4e4e7);
  border-radius: var(--mad-radius-md, 8px);
  padding: 12px;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
}

/* ── Item card wrapper (cards prop) ── */
.mad-tl-item-card {
  background: var(--mad-bg, #fff);
  border: 1px solid var(--mad-border, #e4e4e7);
  border-radius: var(--mad-radius-md, 8px);
  padding: 12px 16px;
}
.mad-timeline--cards .mad-tl-item { padding-bottom: 16px; }
.mad-timeline--cards .mad-tl-item:last-child { padding-bottom: 0; }

/* ── Action links ── */
.mad-tl-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.mad-tl-actions a,
.mad-tl-actions button {
  font-size: 12px;
  font-weight: 500;
  color: #2563eb;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}
.mad-tl-actions a:hover,
.mad-tl-actions button:hover {
  text-decoration: underline;
}

/* ── Date separator ── */
.mad-tl-date-sep {
  position: relative;
  padding: 12px 0;
}
.mad-timeline--both .mad-tl-date-sep {
  text-align: center;
}
.mad-tl-date-sep-label {
  display: inline-block;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--mad-text-muted, #71717a);
  background: var(--mad-bg-muted, #f4f4f5);
  border: 1px solid var(--mad-border, #e4e4e7);
  border-radius: 999px;
  position: relative;
  z-index: 2;
}

/* ── Load more ── */
.mad-tl-load-more {
  text-align: center;
  padding: 16px 0 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SCANNER FIELD — mad-scanner-*
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Input group ── */
.mad-scanner-input-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--mad-border, #d4d4d8);
  border-radius: var(--mad-radius-md, 8px);
  overflow: hidden;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.mad-scanner-input-group:focus-within {
  border-color: var(--mad-primary, #18181b);
  box-shadow: 0 0 0 2px rgba(24,24,27,.08);
}
.mad-scanner-input-group input {
  flex: 1;
  border: none;
  outline: none;
  padding: 8px 12px;
  font-size: 14px;
  background: transparent;
  min-width: 0;
}

/* ── Scan button ── */
.mad-scanner-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  flex-shrink: 0;
  background: var(--mad-bg-muted, #f4f4f5);
  border: none;
  border-left: 1px solid var(--mad-border, #e4e4e7);
  cursor: pointer;
  color: var(--mad-text-muted, #71717a);
  transition: background .2s, color .2s;
}
.mad-scanner-btn:hover {
  background: var(--mad-primary, #18181b);
  color: #fff;
}
.mad-scanner-btn svg { width: 18px; height: 18px; }

/* ── Camera viewfinder container ── */
.mad-scanner-viewfinder {
  margin-top: 8px;
  border-radius: var(--mad-radius-md, 8px);
  overflow: hidden;
  border: 1px solid var(--mad-border, #e4e4e7);
}

/* ── Camera header ── */
.mad-scanner-camera-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #18181b;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
}

/* ── Camera area ── */
.mad-scanner-camera {
  position: relative;
  min-height: 220px;
  background: #09090b;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.mad-scanner-camera video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Camera footer ── */
.mad-scanner-camera-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: #18181b;
  gap: 4px;
}

/* ── Type toggle buttons ── */
.mad-scanner-type-toggle {
  display: inline-flex;
  border-radius: 6px;
  overflow: hidden;
}
.mad-scanner-type-toggle button {
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 500;
  border: none;
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.6);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.mad-scanner-type-toggle button:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
}
.mad-scanner-type-toggle button.active {
  background: #fff;
  color: #18181b;
}

/* ── Close button ── */
.mad-scanner-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.15);
  color: #fff;
  cursor: pointer;
  transition: background .2s;
}
.mad-scanner-close-btn:hover {
  background: rgba(255,255,255,.3);
}
.mad-scanner-close-btn svg { width: 14px; height: 14px; }

/* ── State classes ── */
.mad-scanner-field--success .mad-scanner-input-group {
  border-color: #16a34a;
}
.mad-scanner-field--error .mad-scanner-input-group {
  border-color: var(--mad-danger, #dc2626);
}

/* ── Detected badge ── */
.mad-scanner-detected {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #16a34a;
  margin-top: 6px;
}
.mad-scanner-detected svg { width: 14px; height: 14px; }

/* ── Scanline animation ── */
@keyframes mad-scanline {
  0%   { top: 10%; }
  100% { top: 85%; }
}
.mad-scanner-camera .mad-scanline {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #22c55e, transparent);
  box-shadow: 0 0 8px rgba(34,197,94,.5);
  animation: mad-scanline 2s ease-in-out infinite alternate;
  z-index: 3;
}

/* ── Continuous scan list ── */
.mad-scanner-scan-list {
  max-height: 150px;
  overflow-y: auto;
  margin-top: 8px;
  border: 1px solid var(--mad-border, #e4e4e7);
  border-radius: var(--mad-radius-md, 8px);
}
.mad-scanner-scan-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--mad-border, #e4e4e7);
}
.mad-scanner-scan-list-item:last-child { border-bottom: none; }

.mad-scanner-scan-list-type {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 4px;
  background: var(--mad-bg-muted, #f4f4f5);
  color: var(--mad-text-muted, #71717a);
}

/* ═══════════════════════════════════════════════════════════════════════════
   IMAGE FIELD — mad-image-*
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Dropzone ── */
.mad-image-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  border: 2px dashed var(--mad-border, #d4d4d8);
  border-radius: var(--mad-radius-lg, 12px);
  background: #fff;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  text-align: center;
  gap: 8px;
}
.mad-image-dropzone:hover {
  border-color: var(--mad-text-muted, #a1a1aa);
}
.mad-image-dropzone--dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

.mad-image-dropzone-icon {
  color: var(--mad-text-muted, #a1a1aa);
  margin-bottom: 4px;
}
.mad-image-dropzone-icon svg { width: 32px; height: 32px; }

.mad-image-dropzone-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--mad-text, #18181b);
}
.mad-image-dropzone-text span {
  color: #2563eb;
  text-decoration: underline;
  cursor: pointer;
}

.mad-image-dropzone-formats {
  font-size: 12px;
  color: var(--mad-text-muted, #71717a);
}

.mad-image-dropzone-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

/* ── Preview ── */
.mad-image-preview {
  border: 1px solid var(--mad-border, #e4e4e7);
  border-radius: var(--mad-radius-lg, 12px);
  overflow: hidden;
  background: var(--mad-bg-muted, #f4f4f5);
}
.mad-image-preview-img {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9fafb;
}
.mad-image-preview-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* ── Toolbar ── */
.mad-image-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  background: #fff;
  border-top: 1px solid var(--mad-border, #e4e4e7);
}

.mad-image-toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--mad-radius-md, 8px);
  border: none;
  background: transparent;
  color: var(--mad-text-muted, #71717a);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.mad-image-toolbar-btn:hover {
  background: var(--mad-bg-muted, #f4f4f5);
  color: var(--mad-text, #18181b);
}
.mad-image-toolbar-btn svg { width: 16px; height: 16px; }

.mad-image-toolbar-btn--active {
  background: var(--mad-primary, #18181b);
  color: #fff;
}
.mad-image-toolbar-btn--active:hover {
  background: var(--mad-primary, #18181b);
  color: #fff;
  opacity: .9;
}

.mad-image-toolbar-btn--danger:hover {
  background: #fee2e2;
  color: var(--mad-danger, #dc2626);
}

.mad-image-toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--mad-border, #e4e4e7);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ── Camera ── */
.mad-image-camera {
  border-radius: var(--mad-radius-lg, 12px);
  overflow: hidden;
  border: 1px solid var(--mad-border, #e4e4e7);
}
.mad-image-camera video {
  width: 100%;
  display: block;
  background: #09090b;
}

.mad-image-camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px;
  background: var(--mad-bg-muted, #f4f4f5);
  border-top: 1px solid var(--mad-border, #e4e4e7);
}

/* ── Capture button (iOS-style) ── */
.mad-image-capture-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--mad-text, #18181b);
  background: transparent;
  cursor: pointer;
  transition: transform .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mad-image-capture-btn::after {
  content: '';
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--mad-text, #18181b);
  transition: transform .15s;
}
.mad-image-capture-btn:hover { transform: scale(1.05); }
.mad-image-capture-btn:active::after { transform: scale(.85); }

/* ── Camera switch button ── */
.mad-image-switch-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--mad-border, #d4d4d8);
  background: #fff;
  color: var(--mad-text-muted, #71717a);
  cursor: pointer;
  transition: background .15s;
}
.mad-image-switch-btn:hover {
  background: var(--mad-bg-muted, #f4f4f5);
}
.mad-image-switch-btn svg { width: 16px; height: 16px; }

/* ── Crop modal ── */
.mad-image-crop-container { max-height: 60vh; overflow: hidden; }
.mad-image-crop-container img { max-width: 100%; display: block; }

/* ── Error state ── */
.mad-image-field--error .mad-image-dropzone {
  border-color: var(--mad-danger, #dc2626);
}

/* ═══════════════════════════════════════════════════════════════════
   OTP FIELD
   ═══════════════════════════════════════════════════════════════════ */

.mad-otp-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mad-otp-input {
  width: 48px;
  height: 48px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  border: 1px solid var(--mad-border, #d1d5db);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: var(--mad-input-bg, #fff);
  color: var(--mad-text, #111827);
  caret-color: transparent;
  padding: 0;
  -webkit-text-security: none;
}

.mad-otp-input:focus {
  border-color: var(--mad-primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.mad-otp-input.mad-input-error {
  border-color: var(--mad-danger, #ef4444);
}

.mad-otp-input.mad-input-error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .1);
}

.mad-otp-input:disabled {
  opacity: .5;
  cursor: not-allowed;
  background: var(--mad-bg-muted, #f4f4f5);
}

.mad-otp-separator {
  color: var(--mad-text-subtle, #9ca3af);
  font-size: 18px;
  user-select: none;
  margin: 0 2px;
  line-height: 1;
}


/* ═══════════════════════════════════════════════════════════════════
   48. COMPONENTE — CONTEXT MENU
   ═══════════════════════════════════════════════════════════════════ */

.mad-context { position: relative; }

.mad-context-menu {
  position: absolute;
  min-width: 180px;
  background: var(--mad-bg);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-md);
  box-shadow: var(--mad-shadow-lg, 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1));
  z-index: 200;
  padding: 4px;
}

/* Animacao */
.mad-context-enter       { transition: opacity 120ms ease-out, transform 120ms ease-out; }
.mad-context-enter-start { opacity: 0; transform: scale(.95); }
.mad-context-enter-end   { opacity: 1; transform: scale(1); }
.mad-context-leave       { transition: opacity 80ms ease-in; }
.mad-context-leave-start { opacity: 1; }
.mad-context-leave-end   { opacity: 0; }

/* Item */
.mad-context-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--mad-radius-sm);
  font-size: var(--mad-text-sm);
  color: var(--mad-text);
  cursor: pointer;
  user-select: none;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  text-decoration: none;
  transition: background var(--mad-t);
  line-height: 1.4;
}
.mad-context-item:hover { background: var(--mad-bg-muted); }
.mad-context-item:focus-visible { outline: 2px solid var(--mad-primary); outline-offset: -2px; }
.mad-context-item:disabled,
.mad-context-item[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }

.mad-context-item-icon { width: 14px; height: 14px; flex-shrink: 0; }
.mad-context-item-label { flex: 1; }

/* Variantes */
.mad-context-item-danger       { color: var(--mad-danger); }
.mad-context-item-danger:hover { background: var(--mad-danger-subtle); }

.mad-context-item-success       { color: var(--mad-success); }
.mad-context-item-success:hover { background: var(--mad-success-subtle, rgba(16,185,129,.08)); }

/* Kbd shortcut */
.mad-context-kbd {
  margin-left: auto;
  font-size: 11px;
  font-family: inherit;
  color: var(--mad-text-subtle);
  background: var(--mad-bg-muted);
  border: 1px solid var(--mad-border);
  border-radius: var(--mad-radius-sm);
  padding: 1px 5px;
  line-height: 1.4;
}

/* Separator */
.mad-context-sep { height: 1px; background: var(--mad-border); margin: 4px 0; }

/* Label/heading */
.mad-context-label {
  padding: 5px 10px 3px;
  font-size: var(--mad-text-xs);
  font-weight: 700;
  color: var(--mad-text-subtle);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ═══════════════════════════════════════════════════════════════════
   SIGNATURE FIELD
   ═══════════════════════════════════════════════════════════════════ */

/* ── Main container ── */
.mad-signature {
  border: 1px solid var(--mad-border, #e4e4e7);
  border-radius: var(--mad-radius-lg, 12px);
  overflow: hidden;
  background: #fff;
}

/* ── Mode pills ── */
.mad-signature-modes {
  display: flex;
  gap: 4px;
  padding: 8px 8px 0;
}
.mad-signature-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--mad-radius-md, 8px);
  border: none;
  background: var(--mad-bg-muted, #f4f4f5);
  color: var(--mad-text-muted, #71717a);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.mad-signature-pill:hover {
  background: #e4e4e7;
  color: var(--mad-text, #18181b);
}
.mad-signature-pill.active {
  background: var(--mad-primary, #2563eb);
  color: #fff;
}
.mad-signature-pill svg { width: 14px; height: 14px; }

/* ── Canvas wrapper ── */
.mad-signature-canvas-wrap {
  position: relative;
  margin: 8px;
  border: 1px dashed var(--mad-border, #d4d4d8);
  border-radius: var(--mad-radius-md, 8px);
  background: #fff;
  cursor: crosshair;
}
.mad-signature-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--mad-radius-md, 8px);
}

/* ── Expand button (desktop) ── */
.mad-signature-expand-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--mad-radius-sm, 6px);
  border: 1px solid var(--mad-border, #d4d4d8);
  background: rgba(255,255,255,.85);
  color: var(--mad-text-muted, #71717a);
  cursor: pointer;
  transition: background .15s;
  z-index: 2;
}
.mad-signature-expand-btn:hover {
  background: #fff;
  color: var(--mad-text, #18181b);
}
.mad-signature-expand-btn svg { width: 14px; height: 14px; }

/* ── Toolbar ── */
.mad-signature-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--mad-border, #e4e4e7);
  flex-wrap: wrap;
}
.mad-signature-colors {
  display: flex;
  align-items: center;
  gap: 4px;
}
.mad-signature-color {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  padding: 0;
}
.mad-signature-color:hover { transform: scale(1.1); }
.mad-signature-color.active { border-color: var(--mad-primary, #2563eb); }

.mad-signature-widths {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mad-signature-width {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--mad-radius-sm, 6px);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background .15s;
  padding: 0;
}
.mad-signature-width:hover { background: var(--mad-bg-muted, #f4f4f5); }
.mad-signature-width.active {
  border-color: var(--mad-primary, #2563eb);
  background: #eff6ff;
}
.mad-signature-width-dot {
  border-radius: 50%;
  background: currentColor;
}

.mad-signature-sep {
  width: 1px;
  height: 20px;
  background: var(--mad-border, #e4e4e7);
  margin: 0 2px;
  flex-shrink: 0;
}

.mad-signature-toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--mad-radius-sm, 6px);
  border: none;
  background: var(--mad-bg-muted, #f4f4f5);
  color: var(--mad-text-muted, #71717a);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
  gap: 4px;
}
.mad-signature-toolbar-btn:hover {
  background: #e4e4e7;
  color: var(--mad-text, #18181b);
}
.mad-signature-toolbar-btn svg { width: 14px; height: 14px; }
.mad-signature-toolbar-btn--danger {
  color: var(--mad-danger, #dc2626);
}
.mad-signature-toolbar-btn--danger:hover {
  background: #fee2e2;
  color: var(--mad-danger, #dc2626);
}

/* ── Type mode ── */
.mad-signature-type {
  padding: 12px;
}
.mad-signature-type-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--mad-border, #d4d4d8);
  border-radius: var(--mad-radius-md, 8px);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  background: #fff;
  color: var(--mad-text, #18181b);
}
.mad-signature-type-input:focus {
  border-color: var(--mad-primary, #2563eb);
}
.mad-signature-fonts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.mad-signature-font-card {
  border: 1px solid var(--mad-border, #e4e4e7);
  border-radius: var(--mad-radius-md, 8px);
  padding: 16px 8px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fff;
}
.mad-signature-font-card:hover {
  border-color: var(--mad-text-muted, #a1a1aa);
}
.mad-signature-font-card.active {
  border-color: var(--mad-primary, #2563eb);
  background: #eff6ff;
}
.mad-signature-font-card-preview {
  font-size: 24px;
  line-height: 1.2;
  min-height: 36px;
  color: var(--mad-text, #18181b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mad-signature-font-card-name {
  font-size: 11px;
  color: var(--mad-text-muted, #71717a);
  margin-top: 8px;
}

/* ── Type color picker ── */
.mad-signature-type-colors {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
}

/* ── Upload mode ── */
.mad-signature-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  margin: 8px;
  border: 2px dashed var(--mad-border, #d4d4d8);
  border-radius: var(--mad-radius-md, 8px);
  cursor: pointer;
  transition: border-color .2s, background .2s;
  text-align: center;
  gap: 8px;
  background: #fff;
}
.mad-signature-upload:hover {
  border-color: var(--mad-text-muted, #a1a1aa);
}
.mad-signature-upload--dragover {
  border-color: #2563eb;
  background: #eff6ff;
}
.mad-signature-upload svg { width: 32px; height: 32px; color: var(--mad-text-muted, #a1a1aa); }
.mad-signature-upload-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--mad-text, #18181b);
}
.mad-signature-upload-hint {
  font-size: 12px;
  color: var(--mad-text-muted, #71717a);
}

/* ── Preview state ── */
.mad-signature-preview {
  position: relative;
  margin: 8px;
  border: 1px solid var(--mad-border, #e4e4e7);
  border-radius: var(--mad-radius-md, 8px);
  overflow: hidden;
  background: #fff;
}
.mad-signature-preview-img {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.mad-signature-preview-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.mad-signature-preview-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  border-top: 1px solid var(--mad-border, #e4e4e7);
}

/* ── Fullscreen overlay ── */
.mad-signature-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.mad-signature-fullscreen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--mad-border, #e4e4e7);
}
.mad-signature-fullscreen-header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--mad-text, #18181b);
}
.mad-signature-fullscreen canvas {
  flex: 1;
  display: block;
  width: 100%;
  background: #fff;
}
.mad-signature-fullscreen-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--mad-border, #e4e4e7);
  flex-wrap: wrap;
}

/* ── Empty placeholder ── */
.mad-signature-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 24px;
  color: var(--mad-text-muted, #a1a1aa);
  cursor: pointer;
}
.mad-signature-empty svg { width: 28px; height: 28px; }
.mad-signature-empty-text {
  font-size: 13px;
}

/* ── Error state ── */
.mad-field-error .mad-signature {
  border-color: var(--mad-danger, #dc2626);
}

/* ── Disabled ── */
.mad-signature--disabled {
  opacity: .55;
  pointer-events: none;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .mad-signature-fonts { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   MAD MAIL LAYOUT
   ═══════════════════════════════════════════ */

.mad-mail-layout {
    display: grid;
    grid-template-columns: 220px 360px 1fr;
    height: calc(100vh - 140px);
    border: 1px solid var(--mad-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--mad-bg);
}

/* Sidebar */
.mad-mail-sidebar {
    border-right: 1px solid var(--mad-border);
    background: var(--mad-bg-subtle, var(--mad-bg));
    overflow-y: auto;
}

.mad-mail-folders {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 12px;
}

.mad-mail-folder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--mad-text);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.mad-mail-folder-item:hover {
    background: var(--mad-bg-hover, rgba(0,0,0,0.04));
}

.mad-mail-folder-item.active {
    background: var(--mad-bg-hover, rgba(0,0,0,0.06));
    font-weight: 600;
}

.mad-mail-folder-item span:first-of-type {
    flex: 1;
}

.mad-mail-folder-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--mad-bg-hover, rgba(0,0,0,0.06));
    color: var(--mad-text-muted);
}

.mad-mail-folder-badge-primary {
    background: var(--mad-primary, #3b82f6);
    color: #fff;
}

/* Thread list */
.mad-mail-list {
    border-right: 1px solid var(--mad-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mad-mail-list-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--mad-border);
}

.mad-mail-list-header .mad-field { margin: 0; }

.mad-mail-thread-list {
    flex: 1;
    overflow-y: auto;
}

.mad-mail-thread-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--mad-border);
    cursor: pointer;
    transition: background 0.15s;
}

.mad-mail-thread-item:hover {
    background: var(--mad-bg-hover, rgba(0,0,0,0.02));
}

.mad-mail-thread-item.selected {
    background: var(--mad-bg-hover, rgba(0,0,0,0.04));
}

.mad-mail-thread-item.unread .mad-mail-thread-sender,
.mad-mail-thread-item.unread .mad-mail-thread-subject {
    font-weight: 700;
}

.mad-mail-thread-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.mad-mail-thread-sender {
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mad-mail-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mad-primary, #3b82f6);
    flex-shrink: 0;
}

.mad-mail-thread-date {
    font-size: 11px;
    color: var(--mad-text-muted);
    white-space: nowrap;
}

.mad-mail-thread-subject {
    font-size: 13px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mad-mail-thread-preview {
    font-size: 12px;
    color: var(--mad-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Message panel */
.mad-mail-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mad-mail-panel-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid var(--mad-border);
    gap: 8px;
}

.mad-mail-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--mad-text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mad-mail-toolbar-btn:hover {
    background: var(--mad-bg-hover, rgba(0,0,0,0.06));
    color: var(--mad-text);
}

.mad-mail-toolbar-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.mad-mail-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px;
    border-top: 1px solid var(--mad-border);
}

/* ── Thread view ── */

.mad-mail-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    color: var(--mad-text-muted, #9ca3af);
    gap: 12px;
}

.mad-mail-empty-state p {
    font-size: 14px;
    margin: 0;
}

.mad-mail-thread {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.mad-mail-thread-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--mad-border);
}

.mad-mail-thread-header h3 {
    margin: 0 0 2px;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
}

.mad-mail-thread-meta {
    font-size: 12px;
    color: var(--mad-text-muted, #9ca3af);
}

.mad-mail-thread-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Individual message */
.mad-mail-message {
    padding: 20px 24px;
    border-bottom: 1px solid var(--mad-border);
}

.mad-mail-message.last {
    border-bottom: none;
}

.mad-mail-message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.mad-mail-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.mad-mail-message-meta {
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.mad-mail-message-sender {
    font-size: 13px;
    font-weight: 600;
}

.mad-mail-message-date {
    font-size: 11px;
    color: var(--mad-text-muted, #9ca3af);
    white-space: nowrap;
    margin-left: auto;
}

.mad-mail-message-content {
    font-size: 14px;
    line-height: 1.7;
    padding-left: 48px;
    color: var(--mad-text, #374151);
}

/* Message body */
.mad-message-body img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.mad-message-body a {
    color: var(--mad-primary, #3b82f6);
    text-decoration: underline;
}

.mad-message-body p {
    margin: 0 0 8px;
}

.mad-message-body p:last-child {
    margin-bottom: 0;
}

/* Attachments */
.mad-mail-attachments {
    padding-left: 48px;
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mad-mail-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 16px;
    background: var(--mad-bg-subtle, #f9fafb);
    border: 1px solid var(--mad-border);
    font-size: 12px;
    color: var(--mad-text);
    text-decoration: none;
    transition: background 0.15s;
    max-width: 240px;
}

.mad-mail-attachment-chip:hover {
    background: var(--mad-bg-hover, #f3f4f6);
    text-decoration: none;
    color: var(--mad-text);
}

.mad-mail-attachment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mad-mail-attachment-size {
    color: var(--mad-text-muted, #9ca3af);
    flex-shrink: 0;
}

/* ── Reply box (Gmail-style) ── */

.mad-mail-reply {
    border-top: 1px solid var(--mad-border);
    padding: 16px 24px;
    background: var(--mad-bg);
}

.mad-mail-reply-box {
    margin-bottom: 8px;
}

.mad-mail-reply-box .mad-field {
    margin: 0;
}

.mad-mail-reply-box .mad-label {
    display: none;
}

.mad-mail-reply-box .mad-html-editor-wrap {
    border-radius: 8px;
}

.mad-mail-reply-box .mad-html-editor-wrap .tox-edit-area__iframe {
    min-height: 60px;
    font-size: 13px;
}

.mad-mail-reply-box .mad-html-editor-wrap .tox-toolbar__primary {
    padding: 4px 8px;
}

.mad-mail-reply-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Attach Button (mad-attach-btn) ── */

.mad-attach-btn-wrap {
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
}

.mad-attach-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--mad-text-muted, #6b7280);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mad-attach-btn:hover {
    background: var(--mad-bg-hover, rgba(0,0,0,0.06));
    color: var(--mad-text);
}

.mad-attach-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.mad-attach-btn-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.mad-attach-btn-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--mad-bg-subtle, #f3f4f6);
    border: 1px solid var(--mad-border);
    font-size: 11px;
    color: var(--mad-text-muted);
    max-width: 200px;
}

.mad-attach-btn-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mad-attach-btn-chip-size {
    color: var(--mad-text-muted, #9ca3af);
    flex-shrink: 0;
    font-size: 10px;
}

.mad-attach-btn-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--mad-text-muted);
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
    border-radius: 50%;
    transition: color 0.15s;
}

.mad-attach-btn-chip-remove:hover {
    color: var(--mad-danger, #ef4444);
}

/* Transporter inside mail panel */
.mad-mail-panel .mad-transporter {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mad-mail-panel .mad-transporter-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Responsive */
@media (max-width: 900px) {
    .mad-mail-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .mad-mail-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--mad-border);
    }

    .mad-mail-folders {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }

    .mad-mail-list {
        border-right: none;
        border-bottom: 1px solid var(--mad-border);
        max-height: 50vh;
    }

    .mad-mail-panel {
        min-height: 400px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Avatar Field — circular avatar with upload button
   ═══════════════════════════════════════════════════════════════════════════ */

.mad-avatar-field-header {
    margin-bottom: 12px;
}

.mad-avatar-field-desc {
    font-size: 13px;
    color: var(--mad-text-muted);
    margin-top: 2px;
}

.mad-avatar-field-dropzone {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    border: 1px solid var(--mad-border);
    border-radius: var(--mad-radius-lg, 8px);
    cursor: pointer;
    transition: border-color var(--mad-t), background var(--mad-t);
    margin: 0;
    margin-bottom: 15px;
}

.mad-avatar-field-dropzone:hover {
    border-color: var(--mad-text-muted);
    background: var(--mad-bg-subtle, rgba(0,0,0,.01));
}

.mad-avatar-field-circle {
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--mad-bg-muted);
}

.mad-avatar-field-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mad-avatar-field-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mad-avatar-field-placeholder svg,
.mad-avatar-field-placeholder i[data-lucide] {
    width: 40%;
    height: 40%;
    color: var(--mad-text-muted);
}

.mad-avatar-field-body {
    flex: 1;
    min-width: 0;
}

.mad-avatar-field-help {
    font-size: 13px;
    color: var(--mad-text-muted);
    margin-bottom: 8px;
    line-height: 1.4;
}

.mad-avatar-field-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mad-avatar-field-hints {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--mad-text-muted);
}

.mad-avatar-field-hints span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mad-avatar-field-hints span::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.4;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Settings Nav — sidebar de configuracoes (Profile, Account, etc.)
   ═══════════════════════════════════════════════════════════════════════════ */

.mad-settings-layout {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.mad-settings-nav {
    width: 220px;
    flex-shrink: 0;
    border: 1px solid var(--mad-border);
    border-radius: 8px;
    padding: 4px;
    display: flex;
    flex-direction: column;
}

.mad-settings-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--mad-text);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 2px;
    text-decoration: none;
}

.mad-settings-nav-item:last-child {
    margin-bottom: 0;
}

.mad-settings-nav-item:hover {
    background: var(--mad-bg-muted);
}

.mad-settings-nav-item.active {
    background: var(--mad-bg-muted);
    font-weight: 500;
}

.mad-settings-nav-item.disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.mad-settings-nav-item svg,
.mad-settings-nav-item i[data-lucide] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.mad-settings-content {
    flex: 1;
    max-width: 640px;
    min-width: 0;
}

.mad-settings-avatar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.mad-settings-avatar-img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--mad-bg-muted);
}

.mad-settings-avatar-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mad-settings-avatar-placeholder {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--mad-bg-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mad-settings-avatar-placeholder svg,
.mad-settings-avatar-placeholder i[data-lucide] {
    width: 28px;
    height: 28px;
    color: var(--mad-text-muted);
}

.mad-settings-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid var(--mad-border);
    background: var(--mad-bg);
    color: var(--mad-text);
    cursor: pointer;
    margin: 0;
    transition: background 0.15s;
}

.mad-settings-upload-btn:hover {
    background: var(--mad-bg-muted);
}

.mad-settings-2fa-card {
    padding: 16px;
    border: 1px solid var(--mad-border);
    border-radius: 8px;
}

.mad-settings-2fa-card--success {
    border-color: var(--mad-border-success, #86efac);
    background: var(--mad-bg-success, #f0fdf4);
}

.mad-settings-2fa-method {
    text-align: left;
    padding: 16px;
    border: 1px solid var(--mad-border);
    border-radius: 8px;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    transition: border-color 0.15s;
}

.mad-settings-2fa-method:hover {
    border-color: var(--mad-primary);
}

.mad-settings-section-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.mad-settings-section-desc {
    font-size: 14px;
    color: var(--mad-text-muted);
    margin: 0 0 24px 0;
}

.mad-settings-back-btn {
    margin-bottom: 16px;
}

/* ─── Wizard do 2FA Google Authenticator ─── */
.mad-2fa-step {
    border: 1px solid var(--mad-border);
    border-radius: 10px;
    padding: 16px 18px;
    background: var(--mad-bg, #fff);
}

.mad-2fa-step-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.mad-2fa-step-num {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--mad-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
}

.mad-2fa-step-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.mad-2fa-step-sub {
    font-size: 13px;
    color: var(--mad-text-muted);
    line-height: 1.4;
}

.mad-2fa-store-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-left: 40px;
}

.mad-2fa-store-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--mad-border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--mad-text);
    text-decoration: none;
    background: var(--mad-bg-muted, #f8fafc);
    transition: border-color 0.15s, background 0.15s;
}

.mad-2fa-store-badge:hover {
    border-color: var(--mad-primary);
    background: var(--mad-bg, #fff);
    color: var(--mad-text);
    text-decoration: none;
}

.mad-2fa-qr-wrap {
    display: flex;
    justify-content: center;
    padding: 16px 0;
}

.mad-2fa-qr-img {
    width: 200px;
    height: 200px;
    padding: 10px;
    border: 1px solid var(--mad-border);
    border-radius: 10px;
    background: #fff;
}

.mad-2fa-qr-placeholder {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--mad-border);
    border-radius: 10px;
    color: var(--mad-text-muted);
}

.mad-2fa-secret {
    margin-top: 4px;
}

.mad-2fa-secret-label {
    display: block;
    font-size: 12px;
    color: var(--mad-text-muted);
    margin-bottom: 6px;
}

.mad-2fa-secret-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.mad-2fa-secret-row code {
    flex: 1;
    padding: 10px 12px;
    background: var(--mad-bg-muted, #f8fafc);
    border: 1px solid var(--mad-border);
    border-radius: 6px;
    font-size: 14px;
    letter-spacing: 2px;
    word-break: break-all;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.mad-2fa-secret-copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    border: 1px solid var(--mad-border);
    border-radius: 6px;
    background: var(--mad-bg, #fff);
    color: var(--mad-text);
    cursor: pointer;
    font-size: 13px;
    transition: border-color 0.15s, background 0.15s;
}

.mad-2fa-secret-copy:hover {
    border-color: var(--mad-primary);
    background: var(--mad-bg-muted, #f8fafc);
}

@media (max-width: 768px) {
    .mad-settings-layout {
        flex-direction: column;
        gap: 16px;
    }

    .mad-settings-nav {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }

    .mad-settings-nav-item {
        width: auto;
        flex: 0 0 auto;
        margin-bottom: 0;
    }

    .mad-settings-content {
        max-width: 100%;
    }
}


/* ═══════════════════════════════════════════════════════════════════
   COMPONENTE — SIDEBAR NAV (rail de ícones + painel expansível)
   ═══════════════════════════════════════════════════════════════════ */

.mad-sidebar-nav {
    display: flex;
    align-items: stretch;
}

.mad-sidebar-nav-rail {
    width: 44px;
    border-right: 1px solid var(--mad-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 2px;
    flex-shrink: 0;
}

.mad-sidebar-nav-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    background: transparent;
    color: var(--mad-text-muted);
    border-radius: var(--mad-radius);
    transition: background var(--mad-t), color var(--mad-t);
}

.mad-sidebar-nav-btn:hover {
    background: var(--mad-bg-subtle);
    color: var(--mad-text);
}

.mad-sidebar-nav-btn.active {
    background: var(--mad-bg-subtle);
    color: var(--mad-primary);
}

.mad-sidebar-nav-separator {
    border-top: 1px solid var(--mad-border);
    width: 28px;
    margin: 4px 0;
}

.mad-sidebar-nav-folder {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--mad-radius);
    font-size: 12px;
    margin-bottom: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--mad-text-muted);
    transition: background var(--mad-t), color var(--mad-t);
}

.mad-sidebar-nav-folder:hover {
    background: var(--mad-bg-subtle);
    color: var(--mad-text);
}

.mad-sidebar-nav-folder.active {
    background: var(--mad-primary-bg, rgba(67, 97, 238, 0.08));
    color: var(--mad-primary);
    font-weight: 500;
}

.mad-sidebar-nav-panel {
    width: 200px;
    border-right: 1px solid var(--mad-border);
    padding: 10px;
    flex-shrink: 0;
}

/* ── Tree View ──────────────────────────────────────────────────────── */

.mad-tree {
    font-size: 13px;
    user-select: none;
}

.mad-tree-actions {
    padding: 4px 0;
}

.mad-tree-actions-top {
    margin-bottom: 4px;
}

.mad-tree-actions-bottom {
    margin-top: 4px;
}

.mad-tree-node-content {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--mad-radius, 4px);
    cursor: pointer;
    transition: background 0.15s ease;
    min-height: 26px;
}

.mad-tree-node-content:hover {
    background: var(--mad-bg-subtle, rgba(0, 0, 0, 0.04));
}

.mad-tree-node-content.active {
    background: var(--mad-primary-bg, rgba(67, 97, 238, 0.08));
    color: var(--mad-primary);
    font-weight: 500;
}

.mad-tree-toggle {
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    color: var(--mad-text-muted, #9ca3af);
}

.mad-tree-toggle:hover {
    background: var(--mad-bg-subtle, rgba(0, 0, 0, 0.06));
    color: var(--mad-text, #374151);
}

.mad-tree-toggle-spacer {
    width: 16px;
    flex-shrink: 0;
}

.mad-tree-icon {
    flex-shrink: 0;
    color: var(--mad-text-muted, #9ca3af);
}

.mad-tree-node-content.active .mad-tree-icon {
    color: var(--mad-primary);
}

.mad-tree-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mad-tree-badge {
    font-size: 10px;
    color: var(--mad-text-muted, #9ca3af);
    background: var(--mad-bg-subtle, rgba(0, 0, 0, 0.04));
    border-radius: 8px;
    padding: 0 6px;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
    line-height: 16px;
}

.mad-tree-children {
    /* overflow: hidden; */
}

.mad-tree-node-highlight .mad-tree-node-content {
    animation: mad-tree-flash 1.5s ease;
}

@keyframes mad-tree-flash {
    0%, 100% { background: transparent; }
    20% { background: var(--mad-primary-bg, rgba(67, 97, 238, 0.12)); }
}

/* ──────────────── Tag Chip (row-view partial) ──────────────── */
.mad-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    border: 1px solid;
    line-height: 1.4;
}
.mad-tag-chip button {
    background: none;
    border: 0;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 0 0 2px;
    opacity: 0.6;
    color: inherit;
}
.mad-tag-chip button:hover { opacity: 1; }

/* ── DB Blocks (generic pivot row collection) ── */
.mad-db-blocks { position: relative; }
.mad-db-blocks-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mad-db-blocks-list.mad-db-blocks-stack { flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
.mad-db-blocks-empty { font-size: 12px; color: var(--mad-text-muted, #888); padding: 8px 4px; }
.mad-db-blocks-add {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.4;
    border: 1px dashed var(--mad-border, #444);
    background: transparent;
    color: var(--mad-text-muted, #888);
    cursor: pointer;
    white-space: nowrap;
}
.mad-db-blocks-add:hover {
    border-color: var(--mad-primary, #6366f1);
    color: var(--mad-primary, #6366f1);
}
.mad-db-blocks-stack .mad-db-blocks-add { align-self: flex-start; }
.mad-db-blocks-popover {
    position: absolute;
    z-index: 1000;
    margin-top: 6px;
    min-width: 280px;
    max-width: 360px;
    background: var(--mad-bg, #fff);
    border: 1px solid var(--mad-border, #e5e7eb);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 12px;
}
.mad-db-block-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--mad-border, #e5e7eb);
    border-radius: 6px;
    background: var(--mad-bg, #fff);
}
