/* ==========================================================================
   FormulaFlow — design system (Dark Glass)

   O painel nasce escuro: base.php e auth.php abrem com
   <html data-theme="dark" data-bs-theme="dark">. Os tokens claros em :root
   ficam para as telas de papel (receituário, orçamento público, impressão),
   que usam o layout público e não ligam o escuro.

   Nenhuma cor de marca é fixa aqui: tudo vem das variáveis geradas por
   theme.css (Configurações → Aparência). A paleta padrão da plataforma é
   Lime Signal (#b7e925) + Deep Teal (#1c4040), mas cada farmácia pode trocar.
   Mexer em cor de marca neste arquivo quebra o white-label.
   ========================================================================== */

:root {
    /* --- Fundações (tema claro: documentos e telas públicas) -------------- */

    /* Tinta */
    --ink: #111515;
    --ink-2: #4f5a5a;
    --muted: #66716f;

    /* Superfícies e bordas */
    --surface: #ffffff;
    --surface-field: #f5f7f6;
    --surface-hover: #eef2f0;
    --surface-raised: #eef1f0;   /* ladrilho de ícone, botão secundário */
    --surface-2: var(--surface-field); /* nome antigo usado em algumas views */
    --canvas: #f3f5f4;
    --line: #e2e7e5;
    --line-strong: #cdd5d2;
    --border-strong: #8a9592;

    --mint: #2fae7d;
    --mint-soft: #e2f5ec;

    /* Semânticas (cores de sistema): nunca substituídas pela marca;
       status sempre tem texto. */
    --ok: #1f7a3e;
    --ok-soft: #e6f4ea;
    --ok-ink: #1f7a3e;
    --warn: #8a5a00;
    --warn-soft: #fff3dc;
    --warn-ink: #8a5a00;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --danger-ink: #b42318;
    --info: #1f5fa8;
    --info-soft: #e8f0fb;
    --info-ink: #1f5fa8;

    /* Vidro */
    --topbar-bg: rgba(243, 245, 244, .72);
    --glass-fill: rgba(255, 255, 255, .72);
    --glass-sheet: rgba(255, 255, 255, .78);
    --glass-border: rgba(255, 255, 255, .65);
    --glass-sheen: rgba(255, 255, 255, .5);
    --field-on-glass: rgba(255, 255, 255, .7);
    --scrim: rgba(17, 21, 21, .28);
    --scrim-blur: 14px;

    /* Elevação */
    --shadow-xs: 0 1px 2px rgba(17, 21, 21, .06);
    --shadow-sm: 0 1px 2px rgba(17, 21, 21, .06), 0 2px 6px rgba(17, 21, 21, .05);
    --shadow: 0 4px 12px rgba(17, 21, 21, .08), 0 1px 2px rgba(17, 21, 21, .06);
    --shadow-lg: 0 16px 40px -8px rgba(17, 21, 21, .18), 0 2px 6px rgba(17, 21, 21, .06);
    --shadow-card: 0 1px 2px rgba(17, 21, 21, .05);
    --shadow-glass: 0 24px 48px -12px rgba(17, 21, 21, .22), inset 0 1px 0 rgba(255, 255, 255, .8);
    --shadow-sheet: 0 40px 80px -20px rgba(17, 21, 21, .35), inset 0 1px 0 rgba(255, 255, 255, .8);
    --shadow-pressed: inset 0 1px 2px rgba(17, 21, 21, .12);
    --shadow-highlight: inset 0 1px 0 rgba(255, 255, 255, .6);

    /* Raios (curvas contínuas, à la Apple) */
    --radius-sm: 10px;     /* inputs, itens de menu */
    --radius-md: 14px;     /* botões, ladrilhos, menus */
    --radius-lg: 20px;     /* cards internos */
    --radius-xl: 28px;     /* drawer, painéis */
    --radius-pill: 999px;

    /* Tipografia: SF Pro no ecossistema Apple, Inter nos demais. */
    --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
    --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", system-ui, sans-serif;

    /* Movimento: a curva de "sheet" do iOS — sai rápido, assenta devagar. */
    --ease: cubic-bezier(.2, 0, 0, 1);
    --ease-sheet: cubic-bezier(.32, .72, 0, 1);
    --dur-fast: 150ms;
    --dur: 220ms;
    --dur-sheet: 520ms;

    /* Layout */
    --sidebar-w: 256px;
    --sidebar-w-mini: 80px;
    --header-h: 68px;
    --gutter: 12px;        /* respiro entre as peças flutuantes e a janela */
    --drawer-w: 460px;
    --drawer-w-wide: 680px;
}

/* ==========================================================================
   FormulaFlow Dark — o tema do painel
   Preto quase puro com um sopro do Deep Teal, superfícies em camadas como no
   macOS, hairlines em branco translúcido e vidro nas camadas flutuantes.
   ========================================================================== */

:root[data-theme="dark"] {
    --ink: #f3f6f5;
    --ink-2: #a7b2b0;
    --muted: #7e8a88;          /* ≥ 4,6:1 sobre --surface */

    --canvas: #050707;
    --surface: #0d1111;
    --surface-field: #141919;
    --surface-hover: #182020;
    --surface-raised: #1c2323;
    --line: rgba(255, 255, 255, .07);
    --line-strong: rgba(255, 255, 255, .12);
    --border-strong: rgba(255, 255, 255, .16);

    --mint: #4fd69c;
    --mint-soft: rgba(79, 214, 156, .14);

    /* Cores de sistema do modo escuro da Apple */
    --ok: #30d158;
    --ok-soft: rgba(48, 209, 88, .14);
    --ok-ink: #63e083;
    --warn: #ff9f0a;
    --warn-soft: rgba(255, 159, 10, .14);
    --warn-ink: #ffbf5c;
    --danger: #ff453a;
    --danger-soft: rgba(255, 69, 58, .14);
    --danger-ink: #ff8079;
    --info: #0a84ff;
    --info-soft: rgba(10, 132, 255, .15);
    --info-ink: #6cb3ff;

    --topbar-bg: rgba(5, 7, 7, .55);
    --glass-fill: rgba(22, 28, 28, .62);
    --glass-sheet: rgba(18, 23, 23, .58);
    --glass-border: rgba(255, 255, 255, .10);
    --glass-sheen: rgba(255, 255, 255, .06);
    --field-on-glass: rgba(255, 255, 255, .06);
    --scrim: rgba(0, 0, 0, .38);
    --scrim-blur: 18px;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .25);
    --shadow: 0 8px 24px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .4);
    --shadow-card: inset 0 1px 0 rgba(255, 255, 255, .035), 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-glass: 0 24px 60px -12px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .08);
    --shadow-sheet: 0 40px 100px -20px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .09);
    --shadow-pressed: inset 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-highlight: inset 0 1px 0 rgba(255, 255, 255, .06);

    /* Derivadas da marca, recalculadas para o escuro: translúcidas, então
       funcionam sobre qualquer camada sem virar bloco aceso. */
    --brand-primary-soft: color-mix(in srgb, var(--brand-primary) 15%, transparent);
    --brand-primary-soft-strong: color-mix(in srgb, var(--brand-primary) 26%, transparent);
    --brand-primary-ink: color-mix(in srgb, var(--brand-primary) 72%, #ffffff);
    --brand-glow: color-mix(in srgb, var(--brand-primary) 45%, transparent);

    /* A barra lateral é sempre do tema, seja qual for a cor salva. */
    --brand-sidebar: var(--surface);
    --sidebar-texto: var(--ink-2);
    --sidebar-ativo: var(--ink);
    --sidebar-hover: rgba(255, 255, 255, .04);
    --sidebar-borda: var(--line);

    /* Bootstrap alinhado aos nossos neutros (texto, bordas, .text-muted…) */
    --bs-body-bg: var(--canvas);
    --bs-body-color: var(--ink);
    --bs-emphasis-color: #ffffff;
    --bs-heading-color: var(--ink);
    --bs-secondary-color: var(--muted);
    --bs-tertiary-color: var(--muted);
    --bs-secondary-bg: var(--surface-field);
    --bs-tertiary-bg: var(--surface-hover);
    --bs-border-color: var(--line-strong);
    --bs-border-color-translucent: var(--line);
    --bs-link-color: var(--brand-primary-ink);
    --bs-link-hover-color: var(--brand-primary);
    --bs-code-color: var(--brand-primary-ink);

    color-scheme: dark;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

body {
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: .875rem;
    line-height: 1.5;
    letter-spacing: -.003em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Aurora: dois halos fixos (Deep Teal e um fio de Lime) dão profundidade ao
   preto sem competir com o conteúdo. Ficam atrás de tudo e não rolam. */
[data-theme="dark"] body {
    background:
        radial-gradient(70% 55% at 8% -10%, color-mix(in srgb, var(--brand-secondary) 55%, transparent) 0%, transparent 70%),
        radial-gradient(45% 40% at 100% 0%, color-mix(in srgb, var(--brand-primary) 7%, transparent) 0%, transparent 70%),
        var(--canvas);
    background-attachment: fixed;
}

h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 {
    font-family: var(--font-display);
    letter-spacing: -.02em; font-weight: 650; color: var(--ink);
}
/* Título de página: "large title" — pesado, apertado, curto. */
.content h1.h3, .content h1.h4, .content h1.h5 {
    font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.15;
}
.tabular, .kpi__value, .atd__hora, .table-app td.num { font-variant-numeric: tabular-nums; }
a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: var(--brand-primary-hover); }
/* :where() zera a especificidade: links com classe própria (menu, cards)
   continuam mandando na cor. */
:where([data-theme="dark"]) a { color: var(--brand-primary-ink); }
:where([data-theme="dark"]) a:hover { color: var(--brand-primary); }
hr { border-color: var(--line); opacity: 1; }

::selection { background: var(--brand-primary-soft-strong); color: var(--ink); }

[data-theme="dark"] * { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .14) transparent; }

/* Foco: anel de 2px com offset — visível em qualquer superfície. */
*:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* --------------------------------------------------------------------------
   Estrutura
   -------------------------------------------------------------------------- */

.app { display: flex; min-height: 100vh; }

.app__main {
    flex: 1;
    min-width: 0;                 /* permite que tabelas largas encolham */
    display: flex;
    flex-direction: column;
    margin-left: calc(var(--sidebar-w) + var(--gutter));
    transition: margin-left var(--dur) var(--ease);
}

.app--mini .app__main { margin-left: calc(var(--sidebar-w-mini) + var(--gutter)); }

.content { flex: 1; padding: 22px 32px 40px; }

.app__footer {
    padding: 14px 30px 22px;
    font-size: .7rem;
    color: var(--muted);
    text-align: center;
    opacity: .75;
}

/* --------------------------------------------------------------------------
   Sidebar — duas peças flutuantes (identidade + navegação), como no macOS
   -------------------------------------------------------------------------- */

/* Utilitário ausente no Bootstrap: sem min-width:0 o filho flex não encolhe
   e o texto longo vaza para fora da sidebar. */
.min-width-0 { min-width: 0; }

.sidebar {
    position: fixed;
    top: var(--gutter); bottom: var(--gutter); left: var(--gutter);
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1040;
    transition: width var(--dur) var(--ease), transform .3s var(--ease-sheet);
}

.app--mini .sidebar { width: var(--sidebar-w-mini); }

.sidebar__head,
.sidebar__panel {
    background: var(--brand-sidebar);
    border: 1px solid var(--sidebar-borda, var(--line));
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
}

.sidebar__head { padding: 14px; flex-shrink: 0; }

.sidebar__panel {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: inherit;
}
.sidebar__brand:hover { color: inherit; }

.sidebar__logo {
    width: 42px; height: 42px;
    border-radius: var(--radius-md);
    background: var(--brand-gradient, var(--brand-primary));
    color: var(--brand-on-primary);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-weight: 700; font-size: 1.1rem;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 8px 20px -8px var(--brand-glow, transparent), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.sidebar__logo img { width: 100%; height: 100%; object-fit: contain; }

/* Com logo enviado nas Configurações, ele assina o topo por extenso e a
   inicial vira reserva para a sidebar recolhida. */
.sidebar__brand--logo { display: block; }
.sidebar__logo-img {
    display: block; max-width: 100%; max-height: 44px;
    width: auto; object-fit: contain; object-position: left center;
}
.sidebar__brand--logo .sidebar__brand-txt { display: block; margin-top: 6px; }
.sidebar__logo--mini { display: none; }
.app--mini .sidebar__logo-img { display: none; }
.app--mini .sidebar__logo--mini { display: flex; }

.sidebar__name {
    font-family: var(--font-display);
    font-weight: 650; font-size: 1.02rem; letter-spacing: -.02em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__role { font-size: .72rem; color: var(--muted); }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 10px 10px 6px; }
.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

.sidebar__label {
    font-size: .6875rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .08em; color: var(--muted);
    padding: 16px 10px 8px;
}
.sidebar__label:first-child { padding-top: 6px; }

/* Item: ladrilho de ícone + rótulo. O ativo acende o ladrilho com o
   gradiente da marca; a linha em si continua limpa. */
.nav-link-app {
    display: flex; align-items: center; gap: 12px;
    padding: 4px 8px 4px 4px; border-radius: var(--radius-md);
    color: var(--ink-2); font-size: .84rem; font-weight: 500;
    margin-bottom: 3px;
    white-space: nowrap;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-link-app i {
    width: 36px; height: 36px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 12px;
    background: var(--surface-raised);
    font-size: 1rem;
    box-shadow: var(--shadow-highlight);
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.nav-link-app:hover { background: var(--sidebar-hover); color: var(--ink); }
.nav-link-app:hover i { color: var(--ink); }
.nav-link-app.is-active { color: var(--ink); font-weight: 600; }
.nav-link-app.is-active i {
    background: var(--brand-gradient, var(--brand-primary));
    color: var(--brand-on-primary);
    box-shadow: 0 8px 18px -8px var(--brand-glow, transparent), inset 0 1px 0 rgba(255, 255, 255, .35);
}
/* O "Sair" é um <button> dentro de um form (logout só aceita POST), mas
   precisa ficar idêntico aos links de navegação ao lado. */
.nav-link-app--button {
    width: 100%;
    background: none;
    border: 0;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
}
/* Contador em anel, como na referência: informa sem gritar. */
.nav-link-app__badge {
    margin-left: auto;
    min-width: 24px; height: 24px; padding: 0 7px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
    color: var(--ink-2); font-size: .7rem; font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.nav-link-app.is-active .nav-link-app__badge {
    background: var(--brand-primary); border-color: transparent; color: var(--brand-on-primary);
}

.sidebar__foot { padding: 8px 10px 10px; border-top: 1px solid var(--line); }

.app--mini .sidebar__name,
.app--mini .sidebar__role,
.app--mini .sidebar__label,
.app--mini .nav-link-app span,
.app--mini .nav-link-app__badge { display: none; }
.app--mini .sidebar__head { padding: 14px 0; }
.app--mini .nav-link-app { justify-content: center; padding: 4px; }
.app--mini .sidebar__brand { justify-content: center; }

/* --------------------------------------------------------------------------
   Topbar — vidro fino, sem borda, alinhada às peças flutuantes
   -------------------------------------------------------------------------- */

.topbar {
    position: sticky; top: 0; z-index: 1020;
    min-height: var(--header-h);
    background: var(--canvas);                 /* fallback opaco */
    padding: 12px 32px 12px 20px;
    display: flex; align-items: center; gap: 12px;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .topbar {
        background: var(--topbar-bg);
        -webkit-backdrop-filter: blur(24px) saturate(170%);
        backdrop-filter: blur(24px) saturate(170%);
    }
}
@media (prefers-reduced-transparency: reduce), (forced-colors: active) {
    .topbar { background: var(--canvas); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

.topbar__toggle {
    width: 42px; height: 42px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-field); border: 1px solid var(--line); color: var(--ink-2);
    font-size: 1.15rem; border-radius: var(--radius-md); cursor: pointer;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.topbar__toggle:hover { background: var(--surface-hover); color: var(--ink); }

.topbar__search { flex: 1; max-width: 460px; position: relative; }
.topbar__search i {
    position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
    color: var(--muted); font-size: .95rem; pointer-events: none;
}
.topbar__search input {
    width: 100%; height: 42px; padding: 0 14px 0 42px;
    border: 1px solid var(--line); border-radius: var(--radius-md);
    background: var(--surface-field); font-size: .875rem; color: var(--ink);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.topbar__search input::placeholder { color: var(--muted); }
.topbar__search input:focus {
    outline: 0; border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px var(--brand-primary-soft);
}

.topbar__spacer { flex: 1; }

/* Ícones da topbar (sino) viram ladrilhos do mesmo tamanho do menu. */
.topbar .btn-icon {
    width: 42px; height: 42px; min-height: 42px;
    border-radius: var(--radius-md);
    background: var(--surface-field); border: 1px solid var(--line); color: var(--ink-2);
    font-size: 1.05rem;
}
.topbar .btn-icon:hover { background: var(--surface-hover); color: var(--ink); }

.topbar__user { border-radius: var(--radius-md); }
.topbar__user:hover { background: var(--surface-field); }

.avatar {
    width: 36px; height: 36px; border-radius: 12px;
    background: var(--brand-gradient, var(--brand-primary)); color: var(--brand-on-primary);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .78rem; flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 28px; height: 28px; font-size: .68rem; border-radius: 9px; }
.avatar--lg { width: 52px; height: 52px; font-size: 1.05rem; border-radius: 16px; }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card-app {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--brand-radius);
    box-shadow: var(--shadow-card);
}
.card-app__head {
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 12px;
}
.card-app__title {
    font-family: var(--font-display);
    font-size: 1rem; font-weight: 650; letter-spacing: -.015em;
    margin: 0; display: flex; align-items: center; gap: 10px;
}
.card-app__title i {
    width: 30px; height: 30px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-primary-soft); color: var(--brand-primary-ink); font-size: .95rem;
}
.card-app__body { padding: 22px; }
.card-app__foot {
    padding: 14px 22px; border-top: 1px solid var(--line);
    background: var(--surface-field);
    border-radius: 0 0 var(--brand-radius) var(--brand-radius);
}

/* Card de destaque: o gradiente da marca no lugar do degradê da referência.
   Texto em --brand-on-primary, que o theme.css calcula pelo contraste. */
.card-app--destaque {
    position: relative; overflow: hidden;
    background: var(--brand-gradient, var(--brand-primary));
    border-color: transparent;
    color: var(--brand-on-primary);
    box-shadow: 0 20px 40px -18px var(--brand-glow, transparent), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.card-app--destaque::after {      /* brilho especular no canto */
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(80% 60% at 0% 0%, rgba(255, 255, 255, .28), transparent 60%);
}
.card-app--destaque .kpi__value,
.card-app--destaque .kpi__label { color: inherit; }
.card-app--destaque .kpi__label { opacity: .78; }
.card-app--destaque .kpi__icon { background: rgba(255, 255, 255, .28); color: inherit; }

/* KPI */
.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--brand-radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
    height: 100%;
    display: flex; flex-direction: column; gap: 3px;
    position: relative; overflow: hidden;
}
/* .kpi dentro de .card-app__body: o card já desenha a caixa. */
.card-app > .kpi { background: transparent; border: 0; box-shadow: none; }
.kpi__icon {
    width: 40px; height: 40px; border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; margin-bottom: 10px;
}
.kpi__value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1.05; letter-spacing: -.035em; }
.kpi__label { font-size: .8125rem; color: var(--ink-2); font-weight: 500; }
.kpi__trend { font-size: .73rem; font-weight: 600; margin-top: 5px; }

.tone-primary { background: var(--brand-primary-soft); color: var(--brand-primary-ink); }
.tone-ok      { background: var(--ok-soft);   color: var(--ok-ink); }
.tone-warn    { background: var(--warn-soft); color: var(--warn-ink); }
.tone-danger  { background: var(--danger-soft); color: var(--danger-ink); }
.tone-info    { background: var(--info-soft); color: var(--info-ink); }
.tone-muted   { background: var(--surface-raised); color: var(--muted); }

/* --------------------------------------------------------------------------
   Badges de status
   -------------------------------------------------------------------------- */

.badge-status {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: var(--radius-pill);
    font-size: .75rem; font-weight: 600; letter-spacing: 0;
    white-space: nowrap;
}
.badge-status::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.badge-status--success { background: var(--ok-soft);     color: var(--ok-ink); }
.badge-status--warning { background: var(--warn-soft);   color: var(--warn-ink); }
.badge-status--danger  { background: var(--danger-soft); color: var(--danger-ink); }
.badge-status--info    { background: var(--info-soft);   color: var(--info-ink); }
.badge-status--muted   { background: var(--surface-raised); color: var(--muted); }
.badge-status--brand   { background: var(--brand-primary-soft); color: var(--brand-primary-ink); }
/* Etiqueta sólida (o "#EVENTS" da referência): cor da marca, texto calculado. */
.badge-status--solid   { background: var(--brand-primary); color: var(--brand-on-primary); }
.badge-status--solid::before { display: none; }

/* --------------------------------------------------------------------------
   Botões
   -------------------------------------------------------------------------- */

.btn {
    border-radius: var(--radius-md); font-weight: 600; font-size: .875rem;
    padding: .5rem 1.05rem; min-height: 40px;
    letter-spacing: -.005em;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
                transform var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease);
}
.btn-sm { min-height: 32px; padding: .25rem .75rem; font-size: .8125rem; border-radius: 10px; }
.btn i { font-size: .95rem; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; box-shadow: none; }

.btn-primary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: var(--brand-on-primary);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 20px -10px var(--brand-glow, transparent);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: var(--brand-on-primary);
    filter: brightness(1.08);
}
.btn-primary:disabled { background: var(--brand-primary); border-color: var(--brand-primary); color: var(--brand-on-primary); }

/* Secundário: ladrilho neutro preenchido, como o "Cancel" da referência. */
.btn-outline-primary,
.btn-outline-secondary {
    border-color: var(--line); color: var(--ink); background: var(--surface-raised);
    box-shadow: var(--shadow-highlight);
}
.btn-outline-primary:hover,
.btn-outline-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--line-strong);
    color: var(--ink);
}
.btn-outline-primary:active, .btn-outline-secondary:active { background: var(--surface-hover) !important; color: var(--ink) !important; }

.btn-outline-danger { border-color: transparent; color: var(--danger-ink); background: var(--danger-soft); }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-soft { background: var(--brand-primary-soft); color: var(--brand-primary-ink); border: 0; }
.btn-soft:hover { background: var(--brand-primary-soft-strong); color: var(--brand-primary-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; filter: brightness(1.1); }

.btn-ghost { background: transparent; border: 0; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--ink); }

.btn-icon {
    width: 34px; height: 34px; min-height: 34px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 11px; border: 0; background: transparent; color: var(--muted);
}
.btn-icon:hover { background: var(--surface-hover); color: var(--ink); }
/* Ação destrutiva: fica discreta em repouso e só se anuncia no hover, para não
   virar um alvo vermelho piscando em toda linha da tabela. */
.btn-icon--danger:hover { background: var(--danger-soft); color: var(--danger-ink); }

/* Fechar (modais, alertas): ladrilho com o X, como na referência. */
.btn-close {
    width: 36px; height: 36px; padding: 0; opacity: .7;
    border-radius: 12px; background-size: 11px;
    background-color: var(--surface-raised);
}
.btn-close:hover { opacity: 1; background-color: var(--surface-hover); }
.btn-close:focus { box-shadow: none; }
/* O Bootstrap escuro inverte o X com filter — e inverteria o ladrilho junto.
   Aqui o X já vem claro e o filtro sai. */
[data-theme="dark"] .btn-close {
    filter: none;
    --bs-btn-close-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23f3f6f5'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e");
}

/* --------------------------------------------------------------------------
   Formulários — campos preenchidos, anel de foco suave
   -------------------------------------------------------------------------- */

.form-label { font-size: .8125rem; font-weight: 600; margin-bottom: .4rem; color: var(--ink-2); }
.form-control, .form-select {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: .55rem .8rem;
    min-height: 42px;
    font-size: .875rem;
    color: var(--ink);
    background-color: var(--surface-field);
    box-shadow: none;
    transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
textarea.form-control { min-height: auto; }
.form-control-sm, .form-select-sm { min-height: 32px; padding: .25rem .6rem; font-size: .8125rem; }
.form-control:hover, .form-select:hover { border-color: var(--border-strong); }
.form-control:focus, .form-select:focus {
    border-color: var(--brand-primary);
    background-color: var(--surface-field);
    color: var(--ink);
    outline: 0;
    box-shadow: 0 0 0 4px var(--brand-primary-soft);
}
.form-control:disabled, .form-select:disabled, .form-control[readonly] { opacity: .6; background-color: var(--surface-field); }
.form-control::placeholder { color: var(--muted); opacity: 1; }
.form-control-color { padding: 4px; width: 52px; }
.form-text { font-size: .75rem; color: var(--muted); }
.form-check-input { border-color: var(--border-strong); background-color: var(--surface-field); }
.form-check-input:checked { background-color: var(--brand-primary); border-color: var(--brand-primary); }
.form-check-input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 4px var(--brand-primary-soft); }
/* Interruptor no formato iOS: trilho largo, bolinha clara. */
.form-switch .form-check-input {
    width: 2.6em; height: 1.5em; margin-top: 0; border: 0;
    background-color: var(--surface-raised);
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3.3' fill='%23fff'/%3e%3c/svg%3e");
}
.form-switch .form-check-input:checked {
    background-color: var(--brand-primary);
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3.3' fill='%23fff'/%3e%3c/svg%3e");
}
.form-switch .form-check-input:focus { box-shadow: 0 0 0 4px var(--brand-primary-soft); }
.form-switch .form-check-label { padding-left: .35rem; }
.form-range::-webkit-slider-thumb { background: var(--brand-primary); }
.form-range::-moz-range-thumb { background: var(--brand-primary); }
.form-range::-webkit-slider-runnable-track { background: var(--surface-raised); }
.is-invalid ~ .invalid-feedback { display: block; }
.invalid-feedback { font-size: .76rem; color: var(--danger-ink); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); }

/* --------------------------------------------------------------------------
   Tabelas + DataTables
   -------------------------------------------------------------------------- */

.table { --bs-table-color: var(--ink); --bs-table-border-color: var(--line); }
.table-app { --bs-table-bg: transparent; margin: 0; }
.table-app > thead > tr > th {
    font-size: .75rem; font-weight: 600; text-transform: none;
    letter-spacing: 0; color: var(--muted);
    border-bottom: 1px solid var(--line);
    padding: 12px 16px; white-space: nowrap; background: var(--surface-field);
}
.table-app > tbody > tr > td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    font-size: .875rem;
    color: var(--ink);
    transition: background var(--dur-fast) var(--ease);
}
.table-app > tbody > tr:last-child > td { border-bottom: 0; }
.table-app > tbody > tr:hover > td { background: var(--surface-hover); }

.table-app__title { font-weight: 600; color: var(--ink); }
.table-app__sub { font-size: .76rem; color: var(--muted); }

div.dt-container .dt-search input {
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    padding: .5rem .8rem .5rem 2.2rem; font-size: .85rem; min-width: 240px; color: var(--ink);
    background: var(--surface-field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%237e8a88'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat .75rem center / 14px;
}
div.dt-container .dt-search input:focus {
    outline: none; border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px var(--brand-primary-soft);
}
div.dt-container .dt-search label { display: none; }
div.dt-container .dt-length label { font-size: .8rem; color: var(--muted); }
div.dt-container .dt-length select { border-radius: 8px; border: 1px solid var(--line-strong); font-size: .82rem; background-color: var(--surface-field); color: var(--ink); }
div.dt-container .dt-info { font-size: .8rem; color: var(--muted); padding-top: 12px; }
div.dt-container .dt-paging .page-link {
    border: 0; border-radius: 10px; color: var(--ink-2); font-size: .82rem; margin: 0 2px;
    background: transparent; min-width: 32px; text-align: center;
}
div.dt-container .dt-paging .page-item.active .page-link {
    background: var(--brand-primary); color: var(--brand-on-primary);
}
div.dt-container .dt-paging .page-item.disabled .page-link { background: transparent; color: var(--muted); opacity: .5; }
div.dt-container .dt-paging .page-link:hover { background: var(--surface-hover); color: var(--ink); }
table.dataTable > thead > tr > th.dt-orderable-asc:hover,
table.dataTable > thead > tr > th.dt-orderable-desc:hover { background: var(--surface-hover); }

.table-wrap { overflow-x: auto; }

/* --------------------------------------------------------------------------
   Componentes Bootstrap usados em poucas telas
   -------------------------------------------------------------------------- */

.accordion {
    --bs-accordion-bg: var(--surface);
    --bs-accordion-border-color: var(--line);
    --bs-accordion-border-radius: var(--radius-lg);
    --bs-accordion-inner-border-radius: calc(var(--radius-lg) - 1px);
    --bs-accordion-btn-focus-box-shadow: 0 0 0 4px var(--brand-primary-soft);
    --bs-accordion-active-bg: var(--surface-field);
    --bs-accordion-active-color: var(--ink);
}
.nav-tabs { --bs-nav-tabs-border-color: var(--line); --bs-nav-tabs-link-active-bg: var(--surface); --bs-nav-tabs-link-active-border-color: var(--line) var(--line) var(--surface); }
.nav-tabs .nav-link { color: var(--ink-2); }
.nav-tabs .nav-link.active { color: var(--ink); }
.bg-light { background-color: var(--surface-field) !important; }
.text-dark { color: var(--ink) !important; }
.border, .border-top, .border-bottom, .border-start, .border-end { border-color: var(--line) !important; }

/* --------------------------------------------------------------------------
   Estado vazio
   -------------------------------------------------------------------------- */

.empty { text-align: center; padding: 52px 24px; }
.empty__icon {
    width: 64px; height: 64px; border-radius: 20px;
    background: var(--surface-raised); color: var(--muted);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.6rem; margin-bottom: 16px;
    box-shadow: var(--shadow-highlight);
}
.empty__title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 650; letter-spacing: -.015em; margin-bottom: 5px; }
.empty__text { color: var(--muted); font-size: .86rem; max-width: 400px; margin: 0 auto 18px; }

/* --------------------------------------------------------------------------
   Alertas e avisos
   -------------------------------------------------------------------------- */

.alert { border: 1px solid transparent; border-radius: var(--radius-md); font-size: .875rem; padding: 13px 17px; }
.alert-success { background: var(--ok-soft); color: var(--ok-ink); }
.alert-warning { background: var(--warn-soft); color: var(--warn-ink); }
.alert-danger  { background: var(--danger-soft); color: var(--danger-ink); }
.alert-info    { background: var(--info-soft); color: var(--info-ink); }
[data-theme="dark"] .alert-success { border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
[data-theme="dark"] .alert-warning { border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
[data-theme="dark"] .alert-danger  { border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
[data-theme="dark"] .alert-info    { border-color: color-mix(in srgb, var(--info) 22%, transparent); }

.license-banner {
    background: var(--warn-soft); color: var(--warn-ink);
    margin: var(--gutter) var(--gutter) 0 0;
    padding: 10px 18px; font-size: .8rem; font-weight: 600;
    display: flex; align-items: center; gap: 9px;
    border-radius: var(--radius-md);
    border: 1px solid color-mix(in srgb, var(--warn) 22%, transparent);
}

/* --------------------------------------------------------------------------
   Página de autenticação
   -------------------------------------------------------------------------- */

.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    background: var(--canvas);
}
/* Painel de marca: preto profundo com aurora da marca — Deep Teal subindo
   de um canto, Lime acendendo do outro. */
.auth__aside {
    background:
        radial-gradient(60% 45% at 0% 100%, color-mix(in srgb, var(--brand-primary) 85%, transparent) 0%, color-mix(in srgb, var(--brand-secondary) 80%, transparent) 55%, transparent 100%),
        radial-gradient(90% 80% at 100% 0%, color-mix(in srgb, var(--brand-secondary) 95%, transparent) 0%, transparent 70%),
        #060909;
    color: #fff;
    padding: 52px 52px;
    margin: var(--gutter) 0 var(--gutter) var(--gutter);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, .08);
    display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
}
.auth__aside > * { position: relative; z-index: 1; }
.auth__aside h2 {
    font-family: var(--font-display); font-weight: 700; letter-spacing: -.035em;
    font-size: 2.6rem; line-height: 1.08; max-width: 460px; color: #fff;
}
.auth__aside p { color: rgba(255, 255, 255, .72); max-width: 400px; font-size: 1rem; }
.auth__mark {
    width: 36px; height: 36px; border-radius: 12px;
    background: var(--brand-gradient, var(--brand-primary));
    border: 1px solid rgba(255, 255, 255, .25);
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 1rem; color: var(--brand-on-primary);
}
.auth__wordmark { font-family: var(--font-display); font-weight: 650; font-size: 1.1rem; letter-spacing: -.02em; }
/* Grade sutil (futurista) que some em direção ao centro. */
.auth__aside::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(80% 70% at 50% 40%, #000 0%, transparent 75%);
    mask-image: radial-gradient(80% 70% at 50% 40%, #000 0%, transparent 75%);
}
.auth__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.auth__chips > div {
    padding: 7px 12px; border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    font-size: .8rem; color: rgba(255, 255, 255, .88);
}
.auth__panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth__box { width: 100%; max-width: 380px; }
.auth__box h1, .auth__box .h4 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; }
.auth__logo {
    width: 52px; height: 52px; border-radius: 16px;
    background: var(--brand-gradient, var(--brand-primary));
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 26px; overflow: hidden;
    font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; color: var(--brand-on-primary);
    box-shadow: 0 14px 30px -12px var(--brand-glow, transparent), inset 0 1px 0 rgba(255, 255, 255, .35);
}
/* Logo enviado (largo e quase sempre escuro): quadro claro com respiro. */
.auth__logo:has(img) {
    width: 140px; height: 58px; padding: 8px 12px;
    background: #ffffff; box-shadow: var(--shadow-sm);
}
.auth__logo img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* --------------------------------------------------------------------------
   Página pública (QR de ativo e colaborador)
   -------------------------------------------------------------------------- */

.public-page { max-width: 720px; margin: 0 auto; padding: 26px 18px 60px; }
.public-head {
    background: var(--brand-primary); color: var(--brand-on-primary);
    border-radius: var(--brand-radius); padding: 22px 24px; margin-bottom: 20px;
}

/* --------------------------------------------------------------------------
   Responsivo
   -------------------------------------------------------------------------- */

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(calc(-100% - 2 * var(--gutter))); }
    .sidebar.is-open { transform: translateX(0); }
    .app__main { margin-left: 0; }
    .app--mini .app__main { margin-left: 0; }
    .app--mini .sidebar { width: var(--sidebar-w); }
    .content { padding: 18px 16px 32px; }
    .topbar { padding: 12px 16px; }
    .topbar__search { max-width: none; }
    .license-banner { margin: var(--gutter) var(--gutter) 0; }
    .auth { grid-template-columns: 1fr; }
    .auth__aside { display: none; }
}

@media (max-width: 575.98px) {
    .kpi__value { font-size: 1.5rem; }
    .content { padding: 14px 12px 28px; }
    .content h1.h3, .content h1.h4, .content h1.h5 { font-size: 1.45rem; }
    .card-app__body { padding: 16px; }
    .topbar__search { display: none; }
}

.sidebar-backdrop {
    position: fixed; inset: 0; background: var(--scrim);
    z-index: 1030; opacity: 0; pointer-events: none; transition: opacity .25s var(--ease);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .sidebar-backdrop {
        -webkit-backdrop-filter: blur(var(--scrim-blur));
        backdrop-filter: blur(var(--scrim-blur));
    }
}
.sidebar-backdrop.is-visible { opacity: 1; pointer-events: auto; }

@media print {
    .sidebar, .topbar, .app__footer, .no-print { display: none !important; }
    .app__main { margin-left: 0; }
    body { background: #fff !important; color: #111 !important; }
    .card-app { box-shadow: none; border: 1px solid #ddd; background: #fff; }
}

/* ==========================================================================
   Camadas flutuantes: drawer, menus, toasts e tooltips

   TODO modal do sistema abre como painel lateral de vidro (app.js liga
   .modal--drawer em show.bs.modal; data-drawer="off" é a única saída). O
   fundo recebe scrim + desfoque, para o foco ir inteiro ao painel sem perder
   o contexto de onde ele veio.
   ========================================================================== */

.modal { --bs-modal-bg: var(--surface); --bs-modal-color: var(--ink); --bs-modal-border-color: var(--line); }
.modal-content {
    border: 1px solid var(--line); border-radius: var(--radius-xl);
    background: var(--surface); box-shadow: var(--shadow-lg); color: var(--ink);
}
.modal-header, .modal-footer { border-color: var(--line); padding: 20px 24px; }
.modal-body { padding: 24px; }
.modal-title { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; letter-spacing: -.025em; }

/* Fundo: escurece e desfoca a página. O desfoque entra junto com a opacidade. */
.modal-backdrop { --bs-backdrop-bg: var(--scrim); --bs-backdrop-opacity: 1; }
.modal-backdrop.fade { transition: opacity .35s var(--ease); }
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .modal-backdrop {
        -webkit-backdrop-filter: blur(var(--scrim-blur)) saturate(140%);
        backdrop-filter: blur(var(--scrim-blur)) saturate(140%);
    }
}

/* Drawer: painel flutuante, solto das bordas pelo --gutter, cantos contínuos.
   Desliza da direita na curva de sheet do iOS. O .modal também esmaece em
   .32s: é por essa transição que o Bootstrap espera ao fechar. */
.modal.modal--drawer { padding-right: 0 !important; }
.modal.modal--drawer.fade { transition: opacity .32s var(--ease); }
.modal.modal--drawer .modal-dialog {
    position: fixed; top: var(--gutter); right: var(--gutter); bottom: var(--gutter);
    margin: 0; width: min(var(--drawer-w), calc(100% - 2 * var(--gutter))); max-width: none; min-height: 0;
    display: flex; align-items: stretch;
    transform: translateX(calc(100% + var(--gutter)));
    transition: transform var(--dur-sheet) var(--ease-sheet);
}
.modal.modal--drawer.modal--drawer-wide .modal-dialog { width: min(var(--drawer-w-wide), calc(100% - 2 * var(--gutter))); }
.modal.modal--drawer.show .modal-dialog { transform: none; }
.modal.modal--drawer .modal-content {
    height: 100%; width: 100%; overflow: hidden;
    border-radius: var(--radius-xl);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    box-shadow: var(--shadow-sheet);
}
.modal.modal--drawer .modal-content > form { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.modal.modal--drawer .modal-header {
    flex-shrink: 0; border-bottom: 0; padding: 22px 22px 10px 26px; gap: 12px;
}
.modal.modal--drawer .modal-header .btn-close { margin: 0 0 0 auto; }
.modal.modal--drawer .modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 26px 26px; }
.modal.modal--drawer .modal-footer {
    flex-shrink: 0; padding: 14px 22px; gap: 8px;
    border-top: 1px solid var(--line);
    background: var(--surface-field);
}
.modal.modal--drawer .modal-footer > * { margin: 0; }
.modal.modal--drawer .modal-footer .btn { min-width: 108px; min-height: 42px; }
/* Confirmação curta no painel: o texto respira no topo, não flutua no meio. */
.modal.modal--drawer .modal-body > p:only-child { font-size: .95rem; color: var(--ink-2); }

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .modal.modal--drawer .modal-content {
        background: linear-gradient(180deg, var(--glass-sheen) 0%, transparent 180px), var(--glass-sheet);
        -webkit-backdrop-filter: blur(40px) saturate(180%);
        backdrop-filter: blur(40px) saturate(180%);
        border-color: var(--glass-border);
    }
    .modal.modal--drawer .modal-footer { background: rgba(0, 0, 0, .14); border-top-color: var(--glass-border); }
    [data-theme="light"] .modal.modal--drawer .modal-footer,
    :root:not([data-theme="dark"]) .modal.modal--drawer .modal-footer { background: rgba(255, 255, 255, .4); }
    /* Campos sobre o vidro: translúcidos, para o painel continuar um só. */
    .modal.modal--drawer .form-control,
    .modal.modal--drawer .form-select,
    .modal.modal--drawer .ts-control { background-color: var(--field-on-glass); }
    .modal.modal--drawer .card-app,
    .modal.modal--drawer .kpi { background: var(--field-on-glass); }
}
@media (prefers-reduced-transparency: reduce), (forced-colors: active) {
    .modal.modal--drawer .modal-content { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; border-color: var(--line-strong); }
    .modal.modal--drawer .modal-footer { background: var(--surface-field); }
    .modal-backdrop, .sidebar-backdrop { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
    .modal.modal--drawer .modal-dialog { transform: none; transition: opacity 100ms linear; }
}
@media (max-width: 640px) {
    .modal.modal--drawer { --gutter: 8px; }
    .modal.modal--drawer .modal-dialog { width: calc(100% - 2 * var(--gutter)); top: calc(var(--gutter) * 3); }
    .modal.modal--drawer.modal--drawer-wide .modal-dialog { width: calc(100% - 2 * var(--gutter)); }
    .modal.modal--drawer .modal-content { border-radius: 24px; }
}

.dropdown-menu {
    --bs-dropdown-link-color: var(--ink);
    border: 1px solid var(--line-strong); border-radius: var(--radius-md);
    background: var(--surface-field); box-shadow: var(--shadow-lg); padding: 6px;
    color: var(--ink);
}
.dropdown-item { border-radius: var(--radius-sm); font-size: .875rem; padding: 8px 10px; color: var(--ink); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-hover); color: var(--ink); }
.dropdown-item.active, .dropdown-item:active { background: var(--brand-primary-soft); color: var(--brand-primary-ink); }
.dropdown-divider { border-color: var(--line); }
.dropdown-header { color: var(--muted); font-size: .75rem; }

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .dropdown-menu {
        background: var(--glass-fill);
        -webkit-backdrop-filter: blur(30px) saturate(180%);
        backdrop-filter: blur(30px) saturate(180%);
        border-color: var(--glass-border);
        box-shadow: var(--shadow-glass);
    }
}
@media (prefers-reduced-transparency: reduce), (forced-colors: active) {
    .dropdown-menu { background: var(--surface-field); -webkit-backdrop-filter: none; backdrop-filter: none; border-color: var(--line-strong); }
}

.toast { border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow-lg); }
.tooltip { --bs-tooltip-bg: var(--surface-raised); --bs-tooltip-color: var(--ink); }
.tooltip .tooltip-inner { border-radius: var(--radius-sm); font-size: .75rem; box-shadow: var(--shadow); }
[data-theme="light"] .tooltip, :root:not([data-theme="dark"]) .tooltip { --bs-tooltip-bg: var(--ink); --bs-tooltip-color: #fff; }

/* Skeleton de carregamento: superfície de hover pulsando devagar. */
.skeleton {
    background: var(--surface-hover); border-radius: var(--radius-sm);
    animation: ff-pulse 1.4s var(--ease) infinite;
}
@keyframes ff-pulse { 50% { opacity: .55; } }

/* Bibliotecas de terceiros no escuro (Tom Select, Flatpickr). */
[data-theme="dark"] .ts-control,
[data-theme="dark"] .ts-wrapper.single.input-active .ts-control {
    background: var(--surface-field); border-color: var(--line-strong); color: var(--ink);
    border-radius: var(--radius-sm); min-height: 42px;
}
[data-theme="dark"] .ts-control input { color: var(--ink); }
[data-theme="dark"] .ts-dropdown {
    background: var(--surface-field); border: 1px solid var(--line-strong); color: var(--ink);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .ts-dropdown .active { background: var(--surface-hover); color: var(--ink); }
[data-theme="dark"] .ts-wrapper.multi .ts-control > div { background: var(--brand-primary-soft); color: var(--brand-primary-ink); border-radius: 8px; }
[data-theme="dark"] .flatpickr-calendar {
    background: var(--surface-field); border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-lg); border-radius: var(--radius-md);
}
[data-theme="dark"] .flatpickr-calendar.arrowTop::before,
[data-theme="dark"] .flatpickr-calendar.arrowTop::after { border-bottom-color: var(--surface-field); }
[data-theme="dark"] .flatpickr-months .flatpickr-month,
[data-theme="dark"] .flatpickr-current-month .flatpickr-monthDropdown-months,
[data-theme="dark"] span.flatpickr-weekday,
[data-theme="dark"] .flatpickr-months .flatpickr-prev-month,
[data-theme="dark"] .flatpickr-months .flatpickr-next-month { color: var(--ink); fill: var(--ink); background: transparent; }
[data-theme="dark"] .flatpickr-day { color: var(--ink); }
[data-theme="dark"] .flatpickr-day:hover { background: var(--surface-hover); border-color: transparent; }
[data-theme="dark"] .flatpickr-day.prevMonthDay,
[data-theme="dark"] .flatpickr-day.nextMonthDay,
[data-theme="dark"] .flatpickr-day.flatpickr-disabled { color: var(--muted); opacity: .5; }
[data-theme="dark"] .flatpickr-day.selected,
[data-theme="dark"] .flatpickr-day.selected:hover { background: var(--brand-primary); border-color: var(--brand-primary); color: var(--brand-on-primary); }
[data-theme="dark"] .flatpickr-day.today { border-color: var(--brand-primary); }

/* Ajustes pontuais onde havia cor fixa pensada para fundo claro. */
[data-theme="dark"] .swatch__chip { border-color: rgba(255, 255, 255, .12); }

/* --------------------------------------------------------------------------
   Campanhas — balão de prévia do template (estilo WhatsApp)
   -------------------------------------------------------------------------- */

.wa-balao {
    background: #e7f5d8; color: #1b2b17;
    border-radius: 10px 10px 10px 2px;
    padding: 8px 10px 6px; max-width: 340px;
    box-shadow: 0 1px 1px rgba(0,0,0,.12);
    font-size: .875rem; line-height: 1.4;
}
.wa-balao__cab { font-weight: 700; margin-bottom: 4px; }
.wa-balao__midia { width: 100%; border-radius: 6px; margin-bottom: 6px; display: block; max-height: 180px; object-fit: cover; }
.wa-balao__midia--vazia {
    background: rgba(0,0,0,.08); height: 90px;
    display: flex; align-items: center; justify-content: center; gap: 8px; color: #55604f;
}
.wa-balao__corpo { white-space: normal; word-break: break-word; }
.wa-balao__rodape { color: #6b7466; font-size: .75rem; margin-top: 4px; }
.wa-balao__botao {
    margin-top: 6px; padding: 7px; text-align: center; background: rgba(255,255,255,.7);
    border-radius: 6px; color: #0a7ea4; font-weight: 600; font-size: .82rem;
}

[data-theme="dark"] .wa-balao { background: #1f3a2a; color: #e6f2e1; }
[data-theme="dark"] .wa-balao__rodape { color: #93a89a; }
[data-theme="dark"] .wa-balao__botao { background: rgba(255,255,255,.08); color: #6fc7e8; }
[data-theme="dark"] .wa-balao__midia--vazia { background: rgba(255,255,255,.08); color: #aeb9b2; }

.funil-barra { height: 10px; border-radius: 999px; background: var(--surface-raised); overflow: hidden; }
.funil-barra > span { display: block; height: 100%; background: var(--brand-gradient, var(--brand-primary)); border-radius: 999px; }
