/* =====================================================================
   TIBIA SERVICES PLATFORM — Design System
   CSS único, compilado à mão, sem dependência de CDN ou build Node.
   Tema escuro por padrão + tema claro via [data-theme="light"].
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. Tokens
   --------------------------------------------------------------------- */
:root {
    /* -----------------------------------------------------------------
       Superfícies — preto azulado. A escada de profundidade é curta:
       fundo → superfície → superfície elevada. Quem separa os blocos é
       a borda fina, não uma diferença grande de luminosidade.
       ----------------------------------------------------------------- */
    --bg:            #05070d;
    --bg-grad:       none;
    --bg-2:          #090d16;
    --surface:       #0d1320;
    --surface-2:     #111a2a;
    --surface-3:     #162035;
    --overlay:       rgba(2, 4, 8, .82);

    --border:        #1b2a40;
    --border-soft:   #142033;
    --border-strong: #294059;

    /* Texto em três níveis */
    --text:          #f5f9ff;
    --text-2:        #91a0b5;
    --text-muted:    #75839a;
    --text-muted-2:  #5f6d82;
    --text-faint:    #74839b;

    /* -----------------------------------------------------------------
       Azul é ACCENT, não plano de fundo: botão principal, link, foco,
       item ativo e indicadores. O resto da interface fica escuro.
       ----------------------------------------------------------------- */
    --primary:       #19bfff;
    --primary-600:   #35c8ff;
    --primary-700:   #087db8;
    --primary-soft:  rgba(25, 191, 255, .1);
    --primary-ring:  rgba(25, 191, 255, .28);
    --primary-glow:  rgba(25, 191, 255, .22);
    --on-primary:    #04121c;

    --gold:          #f59e0b;
    --gold-soft:     rgba(245, 158, 11, .12);

    /* Semânticos */
    --success:       #22c55e;
    --success-soft:  rgba(34, 197, 94, .12);
    --warning:       #f59e0b;
    --warning-soft:  rgba(245, 158, 11, .12);
    --danger:        #ef4444;
    --danger-soft:   rgba(239, 68, 68, .12);
    --info:          #19bfff;
    --info-soft:     rgba(25, 191, 255, .1);
    --purple:        #8b7bf7;
    --purple-soft:   rgba(139, 123, 247, .12);
    --muted-soft:    rgba(145, 160, 181, .1);

    /* Verde do WhatsApp — cor de marca, usada só no contato do prestador */
    --wpp:           #25d366;
    --wpp-soft:      rgba(37, 211, 102, .12);

    /* Formas */
    --r-xs: 6px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-full: 999px;

    /* Sombras profundas e neutras + o brilho azul do accent */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow:    0 8px 24px -10px rgba(0, 0, 0, .7);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
    --glow:      0 0 0 1px var(--primary-ring), 0 6px 20px -8px var(--primary-glow);

    /* Escala de espaçamento — múltiplos de 4 */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;

    /* Layout */
    --sidebar-w: 272px;
    --topbar-h:  64px;
    --content-max: 1520px;

    /* -----------------------------------------------------------------
       Tipografia — uma família só em toda a interface, com a escala de
       pesos usada de ponta a ponta (400 texto → 800 número grande).
       Só famílias já presentes no sistema: a CSP não libera CDN.
       ----------------------------------------------------------------- */
    --font: "Inter", "Segoe UI Variable Text", -apple-system, BlinkMacSystemFont,
            "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

    --fw-normal: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;
    --fw-black: 800;

    --transition: 150ms cubic-bezier(.4, 0, .2, 1);
    --transition-slow: 260ms cubic-bezier(.2, 0, .2, 1);
}

/* Tema claro: mesma estrutura e hierarquia, superfícies invertidas.
   O azul escurece para manter contraste sobre fundo claro. */
[data-theme="light"] {
    --bg:            #f4f7fb;
    --bg-grad:       none;
    --bg-2:          #eef2f8;
    --surface:       #ffffff;
    --surface-2:     #f4f7fb;
    --surface-3:     #e8eef6;
    --overlay:       rgba(5, 7, 13, .5);

    --border:        #dbe3ee;
    --border-soft:   #e8eef6;
    --border-strong: #b9c6d8;

    --text:          #0b1220;
    --text-2:        #4a5768;
    --text-muted:    #5f6d82;
    --text-muted-2:  #75839a;
    --text-faint:    #616f85;

    --primary:       #0b6f9e;
    --primary-600:   #095a80;
    --primary-700:   #074867;
    --primary-soft:  rgba(11, 111, 158, .1);
    --primary-ring:  rgba(11, 111, 158, .26);
    --primary-glow:  rgba(11, 111, 158, .18);
    --on-primary:    #ffffff;

    --gold:          #a5670a;
    --gold-soft:     rgba(165, 103, 10, .12);

    --success:       #15803d;
    --success-soft:  rgba(21, 128, 61, .11);
    --warning:       #8f5900;
    --warning-soft:  rgba(143, 89, 0, .12);
    --danger:        #c62828;
    --danger-soft:   rgba(198, 40, 40, .11);
    --info:          #0b6f9e;
    --info-soft:     rgba(11, 111, 158, .1);
    --purple:        #5b46c9;
    --purple-soft:   rgba(91, 70, 201, .11);
    --muted-soft:    rgba(95, 109, 130, .1);

    /* O verde da marca não alcança AA sobre fundo claro; escurecido aqui,
       como já é feito com --success e os demais semânticos. */
    --wpp:           #0f7b43;
    --wpp-soft:      rgba(15, 123, 67, .11);

    --shadow-sm: 0 1px 2px rgba(11, 18, 32, .06);
    --shadow:    0 8px 24px -12px rgba(11, 18, 32, .18);
    --shadow-lg: 0 24px 56px -24px rgba(11, 18, 32, .26);
    --glow:      0 0 0 1px var(--primary-ring), 0 6px 18px -8px var(--primary-glow);
}

/* ---------------------------------------------------------------------
   2. Reset
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--text);
    background-color: var(--bg);
    background-image: var(--bg-grad);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ---------------------------------------------------------------------
   Hierarquia tipográfica global. Uma família só; o que muda é peso,
   tamanho e cor:
     TÍTULO      700/800, apertado, cor primária de texto
     SEÇÃO       600/700
     SUBTÍTULO   400/500, cor secundária
     LABEL       500/600, minúsculo, caixa alta e espaçado
     VALOR       700/800, tabular
   --------------------------------------------------------------------- */
h1, h2, h3, h4, h5 {
    margin: 0;
    font-weight: var(--fw-semibold);
    letter-spacing: -.02em;
    line-height: 1.25;
    color: var(--text);
}
h1 { font-size: 1.55rem; font-weight: var(--fw-bold); letter-spacing: -.03em; }
h2 { font-size: 1.15rem; font-weight: var(--fw-semibold); }
h3 { font-size: 1rem;    font-weight: var(--fw-semibold); }
h4 { font-size: .9rem;   font-weight: var(--fw-semibold); letter-spacing: -.01em; }
h5 { font-size: .82rem;  font-weight: var(--fw-semibold); letter-spacing: -.01em; }

.subtitle {
    color: var(--text-2);
    font-size: .84rem;
    font-weight: var(--fw-normal);
    line-height: 1.5;
}

.label-caps, .overline {
    font-size: .68rem; font-weight: var(--fw-semibold);
    text-transform: uppercase; letter-spacing: .1em;
    color: var(--text-muted);
}

/* Valor grande de destaque (XP realizada, totais, indicadores) */
.value-lg {
    font-size: 1.6rem; font-weight: var(--fw-bold);
    letter-spacing: -.03em; line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}
p  { margin: 0 0 .8em; }
p:last-child { margin-bottom: 0; }

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-600); }

img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border-soft); margin: 1.25rem 0; }

::selection { background: var(--primary-soft); }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

/* ---------------------------------------------------------------------
   3. Utilitários
   --------------------------------------------------------------------- */
.muted     { color: var(--text-muted); }
.faint     { color: var(--text-faint); }
.small     { font-size: .8rem; }
.tiny      { font-size: .72rem; }
.strong    { font-weight: 650; }
.mono      { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num       { font-variant-numeric: tabular-nums; }
.uppercase { text-transform: uppercase; letter-spacing: .07em; }
.nowrap    { white-space: nowrap; }
.truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.text-right{ text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info    { color: var(--info); }
.text-gold    { color: var(--gold); }
.hidden    { display: none !important; }

.flex   { display: flex; }
.grid   { display: grid; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.items-end     { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-end   { justify-content: flex-end; }
.justify-center{ justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-col  { flex-direction: column; }
.flex-1    { flex: 1 1 auto; min-width: 0; }
.gap-1 { gap: .3rem; }  .gap-2 { gap: .55rem; } .gap-3 { gap: .85rem; }
.gap-4 { gap: 1.15rem; } .gap-5 { gap: 1.6rem; }
.mt-1 { margin-top: .35rem; } .mt-2 { margin-top: .7rem; } .mt-3 { margin-top: 1.1rem; }
.mt-4 { margin-top: 1.5rem; } .mt-5 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .35rem; } .mb-2 { margin-bottom: .7rem; }
.mb-3 { margin-bottom: 1.1rem; } .mb-4 { margin-bottom: 1.5rem; }
.w-full { width: 100%; }

/* ---------------------------------------------------------------------
   4. Shell (sidebar + topbar)
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    z-index: 60;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    height: var(--topbar-h);
    padding: 0 var(--sp-5);
    border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
}

/*
   O brasão já traz o próprio escudo. Um quadrado azul atrás
   dele criaria forma dentro de forma, então o contêiner fica
   transparente e só empresta a cor da borda do escudo.
*/
.brand-mark {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    color: var(--primary);
    flex-shrink: 0;
}
.brand-mark svg { width: 31px; height: 35px; }

/* Nas telas de acesso e no instalador o brasão é o elemento principal,
   não um item de menu. Em 31px o cavaleiro vira borrão; aqui ele tem
   espaço para ser lido. */
.auth-card .brand-mark,
.install-shell .brand-mark { width: 48px; height: 54px; }
.auth-card .brand-mark { margin-bottom: var(--sp-5); }
.auth-card .brand-mark svg,
.install-shell .brand-mark svg { width: 48px; height: 54px; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
    font-weight: var(--fw-bold); font-size: .95rem; letter-spacing: -.02em;
    color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-role {
    font-size: .64rem; font-weight: 500;
    text-transform: uppercase; letter-spacing: .1em;
    color: var(--text-faint);
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-3) var(--sp-5); }

.nav-section {
    padding: var(--sp-5) var(--sp-2) var(--sp-2);
    font-size: .64rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .12em;
    color: var(--text-faint);
}
.nav-section:first-child { padding-top: var(--sp-1); }

.nav-item {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: var(--sp-1);
    border-radius: var(--r-sm);
    color: var(--text-2);
    font-size: .875rem; font-weight: 500;
    position: relative;
    transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }

/* Item ativo: fundo azul translúcido, texto azul e um glow contido.
   O fio na borda esquerda ancora a seleção sem pesar. */
.nav-item.active {
    background: linear-gradient(90deg, var(--primary-soft), transparent 85%);
    color: var(--primary);
    font-weight: var(--fw-semibold);
    box-shadow: inset 0 0 0 1px var(--primary-ring);
}
.nav-item.active::before {
    content: ""; position: absolute; left: calc(var(--sp-3) * -1); top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 22px; border-radius: 0 3px 3px 0;
    background: var(--primary);
    box-shadow: 0 0 12px 1px var(--primary-glow);
}
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .75; }
.nav-item:hover .nav-icon { opacity: 1; }
.nav-item.active .nav-icon { opacity: 1; color: var(--primary); }
.nav-badge {
    margin-left: auto;
    background: var(--primary); color: var(--on-primary);
    font-size: .65rem; font-weight: 700;
    padding: .1rem .4rem; border-radius: var(--r-full);
    min-width: 18px; text-align: center;
}
.nav-badge.warning { background: var(--warning); color: var(--on-primary); }

/* Rodapé: quem está logado e o que dá para fazer com a conta */
.sidebar-footer {
    padding: var(--sp-3);
    border-top: 1px solid var(--border-soft);
    flex-shrink: 0;
}

.user-card {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: border-color var(--transition), background var(--transition);
}
.user-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.user-avatar {
    width: 34px; height: 34px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    background: var(--primary); color: var(--on-primary);
    font-size: .8rem; font-weight: 700;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name {
    font-size: .82rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: .68rem; color: var(--text-faint); }

.sidebar-actions { display: flex; flex-direction: column; gap: 2px; margin-top: var(--sp-2); }
.sidebar-actions form { display: contents; }
.sidebar-action {
    display: flex; align-items: center; gap: var(--sp-3);
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    border: 0; background: none;
    border-radius: var(--r-sm);
    font-family: inherit; font-size: .8rem; font-weight: 500;
    color: var(--text-2); text-align: left; cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.sidebar-action:hover { background: var(--surface-2); color: var(--text); }
.sidebar-action svg { flex-shrink: 0; opacity: .75; }
.sidebar-action:hover svg { opacity: 1; }
.sidebar-action.danger { color: var(--text-2); }
.sidebar-action.danger:hover { background: var(--danger-soft); color: var(--danger); }

.sidebar-version {
    margin-top: var(--sp-3);
    padding: 0 var(--sp-3);
    font-size: .68rem; color: var(--text-faint);
}

.main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky; top: 0; z-index: 50;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 0 var(--sp-6);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.topbar-title h1 {
    font-size: .82rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .1em;
    color: var(--text-2);
}

/* Data de hoje, à esquerda dos controles */
.topbar-date {
    font-size: .78rem; color: var(--text-muted);
    white-space: nowrap;
}
.topbar-user {
    font-size: .8rem; font-weight: 500; color: var(--text-2);
    white-space: nowrap; max-width: 220px;
    overflow: hidden; text-overflow: ellipsis;
}

.icon-btn {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    border-radius: var(--r-sm);
    cursor: pointer;
    position: relative;
    transition: all var(--transition);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }

.dot-indicator {
    position: absolute; top: 6px; right: 6px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--danger);
    border: 2px solid var(--surface);
}

.sidebar-toggle { display: none; }

.content {
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--sp-6) var(--sp-6) var(--sp-8);
    animation: page-in 220ms cubic-bezier(.2, 0, .2, 1);
}

@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.impersonation-bar {
    display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
    padding: .6rem 1.4rem;
    background: linear-gradient(90deg, var(--warning-soft), transparent 70%);
    border-bottom: 1px solid var(--warning);
    color: var(--text);
    font-size: .84rem;
}
.impersonation-bar strong { color: var(--warning); }

/* ---------------------------------------------------------------------
   5. Breadcrumbs / cabeçalho de página
   --------------------------------------------------------------------- */
.breadcrumbs {
    display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
    font-size: .76rem; color: var(--text-faint); margin-bottom: var(--sp-3);
}
.breadcrumbs a { color: var(--text-faint); }
.breadcrumbs a:hover { color: var(--text-2); }
.breadcrumbs .sep { opacity: .4; }

.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6);
}
.page-head h1 { margin-bottom: var(--sp-1); }
.page-head .subtitle { color: var(--text-2); font-size: .85rem; }
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   6. Botões
   --------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    font-family: inherit; font-size: .82rem; font-weight: 600; line-height: 1.3;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    text-decoration: none;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

/* Principal: azul chapado com tinta escura e um halo curto no hover. */
.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
    font-weight: var(--fw-semibold);
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-600);
    color: var(--on-primary);
    box-shadow: 0 4px 16px -6px var(--primary-glow);
}
.btn-primary:active:not(:disabled) { transform: translateY(1px); }

/* Estado de carregamento: disco girando no lugar do ícone */
.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading::before {
    content: ""; width: 14px; height: 14px; flex-shrink: 0;
    border: 2px solid currentColor; border-right-color: transparent;
    border-radius: var(--r-full);
    animation: btn-spin 620ms linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-success { background: var(--success); color: var(--on-primary); }
.btn-success:hover:not(:disabled) { filter: brightness(1.06); color: var(--on-primary); }

.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: var(--on-primary); }

.btn-warning { background: var(--warning); color: var(--on-primary); }
.btn-warning:hover:not(:disabled) { filter: brightness(1.06); color: var(--on-primary); }

/* Contato do prestador por WhatsApp. Discreto por padrão — o botão leva
   para fora do sistema, então não compete com as ações da própria tela. */
.btn-wpp { background: var(--wpp-soft); color: var(--wpp); border-color: color-mix(in srgb, var(--wpp) 30%, transparent); }
.btn-wpp:hover:not(:disabled) { background: var(--wpp); color: var(--on-primary); border-color: var(--wpp); }

.text-wpp { color: var(--wpp); }
.btn-ghost.text-wpp:hover:not(:disabled) { background: var(--wpp-soft); color: var(--wpp); }

.link-wpp { display: inline-flex; align-items: center; gap: var(--sp-1); color: var(--wpp); font-weight: 500; }
.link-wpp:hover { text-decoration: underline; color: var(--wpp); }
.link-wpp svg { flex-shrink: 0; }

.btn-link { background: none; border: none; color: var(--primary); padding: var(--sp-1) 2px; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }

.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: .76rem; border-radius: var(--r-xs); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { padding: var(--sp-3) var(--sp-6); font-size: .9rem; }
.btn-block { width: 100%; }
.btn-icon { padding: var(--sp-1); width: 32px; height: 32px; }

.btn-group { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   7. Cards
   --------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: border-color var(--transition);
}

/* Variantes de card com um fio de cor no topo, sem pintar o bloco */
.card.highlight { border-color: var(--primary-ring); box-shadow: var(--glow); }
.card.card-warning { border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.card.card-danger  { border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.card.card-success { border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.card + .card { margin-top: var(--sp-5); }

.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--sp-3); flex-wrap: wrap;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border-soft);
}
.card-head h2, .card-head h3 { font-size: .95rem; font-weight: 600; }
.card-head .subtitle { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: var(--sp-5); }
.card-body.tight { padding: var(--sp-3); }
.card-body.flush { padding: 0; }
.card-foot {
    padding: var(--sp-3) var(--sp-5);
    border-top: 1px solid var(--border-soft);
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--sp-3); flex-wrap: wrap;
}

/* Grade de cards */
.grid-cards {
    display: grid;
    gap: var(--sp-4);
    grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
    margin-bottom: var(--sp-6);
}
.grid-2 { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-main { display: grid; gap: var(--sp-5); grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .grid-main { grid-template-columns: 1fr; } }

/*
   Modificador para quando a coluna principal carrega uma tabela larga.

   Com duas colunas, a tabela fica com ~2/3 do espaço — e uma tabela de
   9 colunas não cabe nisso nem em monitor de 1440px. O que sai da tela
   são as últimas colunas, que por acaso são as de decisão (conferência
   e pagamento). Aqui a tabela toma a largura inteira e o painel de
   apoio desce para baixo dela.

   É modificador, e não mudança na regra base, porque as outras 17 telas
   que usam .grid-main têm tabelas curtas ou nenhuma, e a divisão em
   duas colunas serve bem a elas.
*/
.grid-main.grid-stack { grid-template-columns: minmax(0, 1fr); }

/* Stat card: VALOR grande → LABEL pequeno → complemento */
.stat {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    overflow: hidden;
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.stat:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
    transform: translateY(-1px);
}

.stat-label {
    display: flex; align-items: center; gap: var(--sp-2);
    font-size: .68rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .09em;
    color: var(--text-muted);
    margin-bottom: var(--sp-3);
}
/* Número grande do dashboard: peso 800 e dígitos de largura fixa */
.stat-value {
    font-size: 1.75rem; font-weight: var(--fw-black); letter-spacing: -.035em;
    font-variant-numeric: tabular-nums; line-height: 1.1;
    color: var(--text);
}
.stat-value.sm { font-size: 1.35rem; }
.stat-meta { margin-top: var(--sp-2); font-size: .75rem; color: var(--text-muted); }

/* A cor entra no número, como na referência: diferencia categoria sem
   pintar o card inteiro. */
.stat.success .stat-value { color: var(--success); }
.stat.warning .stat-value { color: var(--warning); }
.stat.danger  .stat-value { color: var(--danger); }
.stat.info    .stat-value { color: var(--info); }
.stat.gold    .stat-value { color: var(--gold); }
.stat.purple  .stat-value { color: var(--purple); }

.stat-icon {
    position: absolute; right: var(--sp-4); top: var(--sp-4);
    width: 28px; height: 28px; border-radius: var(--r-xs);
    display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary);
    font-size: .9rem;
}
.stat.purple .stat-icon { background: var(--purple-soft); color: var(--purple); }
.stat.success .stat-icon { background: var(--success-soft); color: var(--success); }
.stat.warning .stat-icon { background: var(--warning-soft); color: var(--warning); }
.stat.danger  .stat-icon { background: var(--danger-soft);  color: var(--danger); }
.stat.info    .stat-icon { background: var(--info-soft);    color: var(--info); }
.stat.gold    .stat-icon { background: var(--gold-soft);    color: var(--gold); }

/* ---------------------------------------------------------------------
   8. Badges e pílulas
   --------------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: var(--sp-1);
    padding: 3px var(--sp-2);
    font-size: .7rem; font-weight: 600; line-height: 1.5;
    border-radius: var(--r-xs);
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 22%, transparent); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.badge-info    { background: var(--info-soft);    color: var(--info);    border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.badge-muted   { background: var(--muted-soft);   color: var(--text-muted); border-color: var(--border); }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 22%, transparent); }
.badge-gold    { background: var(--gold-soft);    color: var(--gold);    border-color: color-mix(in srgb, var(--gold) 22%, transparent); }
.badge-purple  { background: var(--purple-soft);  color: var(--purple);  border-color: color-mix(in srgb, var(--purple) 22%, transparent); }

.chip {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .28rem .65rem;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--r-full);
    font-size: .78rem; color: var(--text-2);
}
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--text); }

.avatar {
    width: 36px; height: 36px; flex-shrink: 0;
    border-radius: var(--r-full);
    display: grid; place-items: center;
    background: var(--surface-3);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: .78rem; font-weight: 700; letter-spacing: .02em;
}
.avatar.sm { width: 28px; height: 28px; font-size: .68rem; }
.avatar.lg { width: 54px; height: 54px; font-size: 1.05rem; }
.avatar.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }

/* ---------------------------------------------------------------------
   9. Formulários
   --------------------------------------------------------------------- */
.form-grid { display: grid; gap: 1.05rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field.span-2 { grid-column: span 2; }
@media (max-width: 640px) { .field.span-2 { grid-column: span 1; } }

.label {
    font-size: .78rem; font-weight: 600; color: var(--text-2);
    display: flex; align-items: center; gap: .3rem;
}
.label .req { color: var(--danger); }
.hint { font-size: .73rem; color: var(--text-faint); }
.error-text { font-size: .75rem; color: var(--danger); }

.input, .select, .textarea {
    width: 100%;
    min-height: 40px;
    padding: var(--sp-2) var(--sp-3);
    font-family: inherit; font-size: .85rem; font-weight: var(--fw-normal);
    color: var(--text);
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
/* Foco em azul: anel translúcido + borda acesa. É o mesmo sinal em
   todo input, select, textarea e busca do sistema. */
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft), 0 0 14px -4px var(--primary-glow);
    background: var(--surface);
}
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.input[readonly], .input:disabled, .select:disabled { opacity: .6; cursor: not-allowed; }
.textarea { min-height: 88px; resize: vertical; line-height: 1.55; }

.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8dab' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .6rem center;
    background-size: 15px;
    padding-right: 2rem;
}

.input-group { display: flex; }
.input-group .input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .btn { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

.input-prefix {
    display: flex; align-items: center;
    padding: 0 .7rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-right: 0;
    border-radius: var(--r-sm) 0 0 var(--r-sm);
    color: var(--text-muted); font-size: .82rem;
}
.input-prefix + .input { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

.check {
    display: flex; align-items: flex-start; gap: .55rem;
    font-size: .85rem; color: var(--text-2); cursor: pointer;
    padding: .3rem 0;
}
.check input[type="checkbox"], .check input[type="radio"] {
    width: 17px; height: 17px; margin: 1px 0 0;
    accent-color: var(--primary);
    cursor: pointer; flex-shrink: 0;
}

.check-card {
    display: flex; align-items: center; gap: .6rem;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    cursor: pointer;
    transition: all var(--transition);
}
.check-card:hover { border-color: var(--border-strong); }
.check-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

.file-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .4rem;
    padding: 1.25rem 1rem;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface-2);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}
.file-drop:hover, .file-drop.dragover { border-color: var(--primary); background: var(--primary-soft); }
.file-drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop .file-icon { font-size: 1.4rem; }
.file-drop .file-name { font-size: .8rem; color: var(--text); font-weight: 600; word-break: break-all; }
.file-preview { margin-top: .6rem; border-radius: var(--r-sm); border: 1px solid var(--border); max-height: 160px; }

fieldset { border: 0; padding: 0; margin: 0; }
.form-section { padding: 1.15rem; border-top: 1px solid var(--border-soft); }
.form-section:first-child { border-top: 0; }
.form-section-title {
    font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
    color: var(--text-faint); margin-bottom: .9rem;
}

/* Barra de filtros */
.filters {
    display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-end;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-2);
}
.filters .field { flex: 0 1 190px; gap: .25rem; }
.filters .field.grow { flex: 1 1 240px; }
.filters .label { font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--text-faint); }
.filters .input, .filters .select { padding: .45rem .65rem; font-size: .82rem; }

.search-box { position: relative; }
.search-box .input { padding-left: 2.1rem; }
.search-box svg {
    position: absolute; left: .68rem; top: 50%; transform: translateY(-50%);
    width: 15px; height: 15px; color: var(--text-faint); pointer-events: none;
}

/* ---------------------------------------------------------------------
   10. Tabelas
   --------------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.table th {
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    font-size: .66rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .09em;
    color: var(--text-faint);
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky; top: 0; z-index: 1;
}
.table td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-2);
    vertical-align: middle;
}
.table tbody tr { transition: background var(--transition), box-shadow var(--transition); }
.table tbody tr:hover {
    background: var(--surface-2);
    box-shadow: inset 3px 0 0 0 var(--primary);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table td.strong, .table td .strong { color: var(--text); font-weight: 600; }
.table .actions { text-align: right; white-space: nowrap; }
.table .col-num {
    text-align: right;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: .82rem;
}
.table .col-num .cell-sub { font-family: var(--font); }
.table-linked tbody tr { cursor: pointer; }

.cell-main { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.cell-main .title { color: var(--text); font-weight: 600; }
.cell-sub { font-size: .74rem; color: var(--text-faint); }

/* Empilhamento no celular */
@media (max-width: 720px) {
    .table.stack thead { display: none; }
    .table.stack tbody tr {
        display: block;
        padding: .8rem .9rem;
        border-bottom: 1px solid var(--border);
    }
    .table.stack tbody td {
        display: flex; align-items: center; justify-content: space-between;
        gap: 1rem; padding: .3rem 0; border: 0; text-align: right;
    }
    .table.stack tbody td::before {
        content: attr(data-label);
        font-size: .7rem; font-weight: 700; text-transform: uppercase;
        letter-spacing: .06em; color: var(--text-faint);
        text-align: left; flex-shrink: 0;
    }
    .table.stack td.actions { justify-content: flex-end; padding-top: .6rem; }
}

/* ---------------------------------------------------------------------
   11. Paginação
   --------------------------------------------------------------------- */
.pagination { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.pagination a, .pagination span {
    min-width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 .5rem;
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    font-size: .8rem; font-weight: 600;
    color: var(--text-2);
    background: var(--surface);
    transition: all var(--transition);
}
.pagination a:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ---------------------------------------------------------------------
   12. Progresso
   --------------------------------------------------------------------- */
.progress {
    height: 9px;
    background: var(--surface-3);
    border-radius: var(--r-full);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: var(--r-full);
    transition: width 600ms cubic-bezier(.4,0,.2,1);
}
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.gold    { background: var(--gold); }
.progress.lg { height: 14px; }
.progress.sm { height: 5px; }

.progress-blocks { display: flex; gap: 3px; }
.progress-block {
    flex: 1; height: 22px;
    border-radius: 3px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    position: relative;
}
.progress-block.done { background: var(--success); border-color: transparent; }
.progress-block.running { background: var(--info); border-color: transparent; animation: pulse 1.8s ease-in-out infinite; }
.progress-block.cancelled { background: var(--danger-soft); border-color: var(--danger); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ---------------------------------------------------------------------
   13. Timeline
   --------------------------------------------------------------------- */
.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before {
    content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px;
    width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 1.05rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: ""; position: absolute; left: -1.6rem; top: 5px;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--border-strong);
}
.timeline-item.success::before { border-color: var(--success); background: var(--success-soft); }
.timeline-item.warning::before { border-color: var(--warning); background: var(--warning-soft); }
.timeline-item.danger::before  { border-color: var(--danger);  background: var(--danger-soft); }
.timeline-item.info::before    { border-color: var(--info);    background: var(--info-soft); }
.timeline-title { font-size: .865rem; color: var(--text); font-weight: 550; }
.timeline-meta { font-size: .74rem; color: var(--text-faint); margin-top: .1rem; }

/* Feed de atividades */
.activity-item {
    display: flex; gap: .75rem; align-items: flex-start;
    padding: .7rem 0;
    border-bottom: 1px solid var(--border-soft);
}
.activity-item:last-child { border-bottom: 0; }
.activity-icon {
    width: 30px; height: 30px; flex-shrink: 0;
    border-radius: var(--r-sm);
    display: grid; place-items: center;
    background: var(--muted-soft);
    font-size: .85rem;
}
.activity-icon.success { background: var(--success-soft); }
.activity-icon.warning { background: var(--warning-soft); }
.activity-icon.danger  { background: var(--danger-soft); }
.activity-icon.info    { background: var(--info-soft); }
.activity-body { min-width: 0; flex: 1; }
.activity-text { font-size: .845rem; color: var(--text-2); }
.activity-meta { font-size: .72rem; color: var(--text-faint); margin-top: .12rem; }

/* ---------------------------------------------------------------------
   14. Alertas / flash
   --------------------------------------------------------------------- */
.alert {
    display: flex; align-items: flex-start; gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    border: 1px solid;
    font-size: .855rem; line-height: 1.5;
    margin-bottom: var(--sp-4);
}
.alert-icon { flex-shrink: 0; font-size: 1rem; line-height: 1.35; }
.alert-body { flex: 1; min-width: 0; }
.alert-close { background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 .2rem; }
.alert-close:hover { opacity: 1; }

.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: var(--success); }
.alert-error, .alert-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); color: var(--warning); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); color: var(--info); }

.flash-stack { position: fixed; top: 78px; right: 1.2rem; z-index: 120; width: min(380px, calc(100vw - 2.4rem)); }
/* Toast: sobe do fundo do card, com sombra funda e uma faixa da cor
   do estado à esquerda — o mesmo vocabulário dos alertas embutidos. */
.flash-stack .alert {
    box-shadow: var(--shadow-lg);
    background-color: var(--surface);
    border-left-width: 3px;
    animation: slide-in 240ms cubic-bezier(.2,.8,.3,1);
}
@keyframes slide-in { from { opacity: 0; transform: translateX(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------------
   15. Estados vazios e skeleton
   --------------------------------------------------------------------- */
.empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .55rem;
    padding: 3rem 1.5rem;
    text-align: center;
}
.empty-icon {
    width: 58px; height: 58px;
    display: grid; place-items: center;
    border-radius: var(--r-lg);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 1.5rem;
    margin-bottom: .3rem;
}
.empty h3 { font-size: 1rem; }
.empty p { color: var(--text-muted); font-size: .865rem; max-width: 46ch; }

.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
    border-radius: var(--r-xs);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-line { height: 12px; margin-bottom: .5rem; }
.skeleton-chart { height: 240px; border-radius: var(--r-sm); }

/* ---------------------------------------------------------------------
   16. Modais
   --------------------------------------------------------------------- */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 200;
    background: var(--overlay);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center; justify-content: center;
    padding: 1.2rem;
    overflow-y: auto;
}
.modal-backdrop.open { display: flex; }

.modal {
    width: min(620px, 100%);
    max-height: calc(100vh - 2.4rem);
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    animation: modal-in 200ms cubic-bezier(.2,.8,.3,1);
}
.modal.sm { width: min(440px, 100%); }
.modal.lg { width: min(900px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }

.modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: .8rem;
    padding: 1rem 1.2rem; border-bottom: 1px solid var(--border-soft);
}
.modal-head h3 { font-size: 1rem; }
.modal-body { padding: 1.2rem; overflow-y: auto; }
.modal-foot {
    display: flex; align-items: center; justify-content: flex-end; gap: .55rem; flex-wrap: wrap;
    padding: .95rem 1.2rem; border-top: 1px solid var(--border-soft); background: var(--surface-2);
}

/* Visualizador de imagem */
.lightbox {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(3, 5, 10, .92);
    display: none; align-items: center; justify-content: center;
    padding: 1.5rem;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 88vh; border-radius: var(--r-md); box-shadow: var(--shadow-lg); }
.lightbox-close {
    position: absolute; top: 1.1rem; right: 1.2rem;
    width: 40px; height: 40px; border-radius: var(--r-full);
    background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
    color: #fff; font-size: 1.2rem; cursor: pointer;
}
.lightbox-caption { position: absolute; bottom: 1.2rem; color: #cfd7e6; font-size: .82rem; }

/* ---------------------------------------------------------------------
   17. Dropdown
   --------------------------------------------------------------------- */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + .45rem);
    min-width: 224px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    padding: .35rem;
    display: none;
    z-index: 90;
}
.dropdown-menu.open { display: block; animation: modal-in 140ms ease-out; }
.dropdown-menu.wide { min-width: 340px; }
.dropdown-item {
    display: flex; align-items: center; gap: .55rem;
    width: 100%;
    padding: .5rem .6rem;
    border: 0; background: none;
    border-radius: var(--r-xs);
    font-family: inherit; font-size: .84rem; color: var(--text-2);
    text-align: left; cursor: pointer;
    transition: background var(--transition);
}
.dropdown-item:hover { background: var(--surface-3); color: var(--text); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); }
.dropdown-divider { height: 1px; background: var(--border-soft); margin: .3rem 0; }
.dropdown-head { padding: .55rem .6rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); }

/* Lista de notificações */
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item {
    display: flex; gap: .6rem; padding: .6rem;
    border-radius: var(--r-xs); color: var(--text-2);
    transition: background var(--transition);
}
.notif-item:hover { background: var(--surface-3); }
.notif-item.unread { background: var(--primary-soft); }
.notif-title { font-size: .82rem; font-weight: 600; color: var(--text); }
.notif-msg { font-size: .76rem; color: var(--text-muted); }
.notif-time { font-size: .69rem; color: var(--text-faint); margin-top: .15rem; }

/* ---------------------------------------------------------------------
   18. Abas
   --------------------------------------------------------------------- */
.tabs {
    display: flex; gap: var(--sp-1); overflow-x: auto;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-6);
}
.tab {
    padding: var(--sp-3) var(--sp-4);
    font-size: .84rem; font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------------------------------------------------------------------
   19. Prints e blocos de XP
   --------------------------------------------------------------------- */
.print-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.print-box {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--surface-2);
}
.print-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: .6rem .85rem;
    font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em;
    color: var(--text-faint);
    border-bottom: 1px solid var(--border-soft);
}
.print-img {
    display: block; width: 100%; height: 200px;
    object-fit: cover; cursor: zoom-in;
    background: var(--surface-3);
    transition: opacity var(--transition);
}
.print-img:hover { opacity: .88; }
.print-empty {
    height: 200px; display: grid; place-items: center;
    color: var(--text-faint); font-size: .8rem; gap: .4rem;
}
.print-arrow { display: grid; place-items: center; color: var(--text-faint); font-size: 1.3rem; }

/* Bloco de XP: inicial e final discretos, XP realizada em destaque.
   O resultado é o que a pessoa precisa ler primeiro. */
.xp-box {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--bg-2);
}
.xp-box-head {
    padding: .55rem .95rem;
    font-size: .7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .1em;
    color: var(--text-faint);
    background: var(--surface-3);
    border-bottom: 1px solid var(--border);
}
.xp-rows { padding: .9rem .95rem; display: flex; flex-direction: column; gap: .75rem; }
.xp-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.xp-row .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); }
.xp-row .v { font-family: var(--font-mono); font-size: 1rem; font-variant-numeric: tabular-nums; color: var(--text-2); }
.xp-total { border-top: 1px solid var(--border); padding-top: var(--sp-3); margin-top: var(--sp-1); }
.xp-total .k { color: var(--text); font-weight: var(--fw-semibold); }
.xp-total .v { font-size: 1.5rem; font-weight: var(--fw-bold); letter-spacing: -.03em; color: var(--success); }
.xp-total.negative .v { color: var(--danger); }

.kv-list { display: grid; gap: .55rem; }
.kv {
    display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
    padding-bottom: .5rem; border-bottom: 1px dashed var(--border-soft);
}
.kv:last-child { border-bottom: 0; padding-bottom: 0; }
.kv .k { font-size: .78rem; color: var(--text-muted); }
.kv .v { font-size: .875rem; color: var(--text); font-weight: 600; text-align: right; }

.arrow-pair {
    display: inline-flex; align-items: center; gap: .35rem;
    font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.arrow-pair .arrow { color: var(--text-faint); }

/* ---------------------------------------------------------------------
   20. Gráficos
   --------------------------------------------------------------------- */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .7rem; font-size: .76rem; color: var(--text-muted); }
.chart-legend .item { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.chart-tooltip {
    position: absolute; pointer-events: none;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-xs);
    padding: .4rem .6rem;
    font-size: .75rem; color: var(--text);
    box-shadow: var(--shadow);
    opacity: 0; transition: opacity 120ms;
    white-space: nowrap; z-index: 5;
}
.chart-tooltip.show { opacity: 1; }

/* ---------------------------------------------------------------------
   21. Telas de autenticação
   --------------------------------------------------------------------- */
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: var(--sp-6);
    padding: var(--sp-6);
    background: var(--bg);
}
@media (max-width: 1024px) { .auth-shell { grid-template-columns: 1fr; padding: var(--sp-4); } }

/* -------- Painel de apresentação (esquerda) -------- */
.auth-side {
    position: relative;
    padding: var(--sp-8);
    display: flex; flex-direction: column; gap: var(--sp-6);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    background:
        radial-gradient(760px 460px at 12% 8%, rgba(25, 191, 255, .14), transparent 60%),
        radial-gradient(620px 460px at 92% 78%, rgba(8, 125, 184, .16), transparent 58%),
        var(--bg-2);
    overflow: hidden;
}
/* ---------------------------------------------------------------------
   Abaixo de 1024px o painel de apresentação sai: manchete, cartões de
   recurso e faixa de garantias não cabem ao lado do formulário.
   Só que a arte ia embora junto com ele, e a tela de acesso ficava um
   retângulo preto. Aqui ela volta — não como painel, mas como fundo da
   tela inteira, com o formulário flutuando por cima.
   ------------------------------------------------------------------ */
@media (max-width: 1024px) {
    .auth-side { display: none; }

    .auth-shell {
        position: relative;
        /* Prende os pseudo-elementos de z-index negativo a este
           contexto: sem isto eles cairiam atrás do fundo do body. */
        isolation: isolate;
    }

    /* A arte. `fixed` para ela não deslizar junto com o formulário. */
    .auth-shell::before {
        content: "";
        position: fixed;
        inset: 0;
        background-image: var(--auth-art, none);
        background-size: cover;
        /* O personagem vive por volta de 66% da largura da imagem. Num
           recorte estreito, centralizar deixaria só o nebuloso da
           esquerda em cena — o enquadramento persegue ele. */
        background-position: 66% center;
        opacity: .46;
        z-index: -2;
        pointer-events: none;
    }

    /*
       Véu de leitura, construído a partir de --bg para acompanhar o
       tema — como já faz o véu do painel no desktop.

       O peso é vertical, não uniforme: no desktop a arte fica de um
       lado e o formulário do outro; aqui os dois dividem a mesma
       coluna, então a separação passa a ser em cima e embaixo. O topo
       abre para a espada e o rosto aparecerem, e a partir de ~40% ele
       fecha, que é onde os campos começam.
    */
    .auth-shell::after {
        content: "";
        position: fixed;
        inset: 0;
        background: linear-gradient(
            180deg,
            color-mix(in srgb, var(--bg) 52%, transparent) 0%,
            color-mix(in srgb, var(--bg) 60%, transparent) 20%,
            color-mix(in srgb, var(--bg) 86%, transparent) 42%,
            color-mix(in srgb, var(--bg) 94%, transparent) 100%
        );
        z-index: -1;
        pointer-events: none;
    }

    /* A arte é escura; sobre o tema claro ela precisa recuar bem mais. */
    [data-theme="light"] .auth-shell::before { opacity: .22; }
}

/* Malha tênue: textura tecnológica sem virar ruído */
.auth-side::before {
    content: "";
    position: absolute; inset: 0;
    background-image:
        linear-gradient(var(--border-soft) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
    background-size: 48px 48px;
    opacity: .6;
    mask-image: radial-gradient(circle at 25% 22%, #000 8%, transparent 70%);
    pointer-events: none;
}
.auth-side > * { position: relative; z-index: 1; }

/* Mesma regra do mark da sidebar: o escudo é a própria forma. */
.auth-brand {
    width: 46px; height: 52px;
    display: grid; place-items: center;
    color: var(--primary);
    filter: drop-shadow(0 8px 22px var(--primary-glow));
}
.auth-brand svg { width: 46px; height: 52px; }

/* Selo "SISTEMA PROFISSIONAL" */
.auth-badge {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--r-full);
    border: 1px solid var(--primary-ring);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: .66rem; font-weight: var(--fw-bold);
    text-transform: uppercase; letter-spacing: .12em;
    width: fit-content;
}
.auth-badge svg { width: 13px; height: 13px; }

.auth-headline {
    font-size: clamp(2rem, 3.4vw, 3rem);
    font-weight: var(--fw-black);
    letter-spacing: -.035em;
    line-height: 1.05;
    color: var(--text);
    margin: var(--sp-4) 0 var(--sp-4);
    max-width: 15ch;
}
.auth-headline .accent { color: var(--primary); }
.auth-lead { color: var(--text-2); font-size: .92rem; line-height: 1.6; max-width: 46ch; }

/* Área de conteúdo + arte lado a lado */
.auth-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .82fr); gap: var(--sp-6); align-items: center; }
@media (max-width: 1320px) { .auth-body { grid-template-columns: 1fr; } .auth-art { display: none; } }

/* -------- Cartões de recurso -------- */
.auth-features { display: grid; gap: var(--sp-3); margin-top: var(--sp-6); }
.auth-feature {
    display: flex; gap: var(--sp-4); align-items: flex-start;
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--surface) 72%, transparent);
    transition: border-color var(--transition), background var(--transition);
}
.auth-feature:hover { border-color: var(--primary-ring); background: var(--surface); }
.auth-feature .ico {
    width: 40px; height: 40px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: var(--r-md);
    border: 1px solid var(--primary-ring);
    background: var(--primary-soft);
    color: var(--primary);
}
.auth-feature .ico svg { width: 19px; height: 19px; }
.auth-feature-title { font-size: .9rem; font-weight: var(--fw-semibold); color: var(--text); margin-bottom: 2px; }
.auth-feature-desc { font-size: .8rem; color: var(--text-2); line-height: 1.5; }

/* -------- Faixa inferior de garantias -------- */
.auth-strip {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4);
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--surface) 72%, transparent);
}
@media (max-width: 1500px) { .auth-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.auth-strip-item { display: flex; gap: var(--sp-3); align-items: center; min-width: 0; }
.auth-strip-item .ico {
    width: 32px; height: 32px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    background: var(--primary-soft); color: var(--primary);
}
.auth-strip-item .ico svg { width: 16px; height: 16px; }
.auth-strip-title { font-size: .8rem; font-weight: var(--fw-semibold); color: var(--text); }
.auth-strip-desc { font-size: .72rem; color: var(--text-muted); }

.auth-foot-note {
    display: flex; align-items: center; gap: var(--sp-2);
    font-size: .74rem; color: var(--text-muted);
}
.auth-foot-note .dot {
    width: 7px; height: 7px; border-radius: var(--r-full);
    background: var(--success);
    box-shadow: 0 0 8px 1px color-mix(in srgb, var(--success) 60%, transparent);
    flex-shrink: 0;
}

/* -------- Arte de fundo do painel --------
   O personagem ocupa a metade direita do painel e o conteúdo passa por
   cima. Os dois véus (horizontal e vertical) garantem que o texto
   continue legível por cima da arte, como na referência. */
.auth-art-bg {
    position: absolute;
    inset: 0 0 0 18%;
    /* A imagem vem do `--auth-art` declarado no .auth-shell pelo PHP. */
    background-image: var(--auth-art, none);
    /* Ponto focal da arte. Se o personagem ficar cortado, mexa só aqui:
       "center", "center right", "60% 40%" etc. */
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    opacity: .9;
    pointer-events: none;
    z-index: 0;
}
.auth-art-bg::after {
    content: "";
    position: absolute; inset: 0;
    background:
        linear-gradient(90deg, var(--bg-2) 0%, color-mix(in srgb, var(--bg-2) 78%, transparent) 26%, transparent 62%),
        linear-gradient(0deg, var(--bg-2) 2%, transparent 42%),
        radial-gradient(60% 55% at 62% 38%, rgba(25, 191, 255, .18), transparent 70%);
}
/* Com arte de fundo o conteúdo não divide espaço com a ilustração */
.auth-side.has-art .auth-body { grid-template-columns: minmax(0, 1fr); }
.auth-side.has-art .auth-art { display: none; }
.auth-side.has-art .auth-headline,
.auth-side.has-art .auth-lead,
.auth-side.has-art .auth-features { max-width: 34rem; }

/* -------- Arte -------- */
.auth-art { position: relative; display: grid; place-items: center; min-height: 340px; }
.auth-art svg { width: 100%; max-width: 380px; height: auto; }

/* -------- Painel do formulário (direita) -------- */
.auth-main {
    display: flex; align-items: center; justify-content: center;
    padding: var(--sp-6) var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    background:
        radial-gradient(520px 320px at 50% -8%, rgba(25, 191, 255, .1), transparent 62%),
        var(--bg-2);
}
@media (max-width: 1024px) { .auth-main { border: 0; background: none; padding: var(--sp-4) 0; } }

.auth-card { width: min(460px, 100%); }
.auth-card h1 { font-size: 1.6rem; margin-bottom: var(--sp-2); letter-spacing: -.03em; }
.auth-card h1 .accent { color: var(--primary); }
.auth-card .lead { color: var(--text-2); font-size: .875rem; line-height: 1.6; margin-bottom: var(--sp-6); }
.auth-form { display: grid; gap: var(--sp-4); }
.auth-foot { margin-top: var(--sp-5); text-align: center; font-size: .82rem; color: var(--text-muted); }

/* Emblema circular com anel e brilho (telas de estado: espera, vencida) */
.auth-emblem {
    width: 108px; height: 108px; margin: 0 auto var(--sp-6);
    display: grid; place-items: center;
    border-radius: var(--r-full);
    border: 2px solid var(--primary);
    background: radial-gradient(circle at 50% 50%, var(--primary-soft), transparent 68%);
    color: var(--primary);
    box-shadow: 0 0 0 10px color-mix(in srgb, var(--primary) 6%, transparent),
                0 0 44px -6px var(--primary-glow);
    position: relative;
}
.auth-emblem svg { width: 42px; height: 42px; }
.auth-emblem::after {
    content: "";
    position: absolute; inset: -22px;
    border-radius: var(--r-full);
    background: radial-gradient(circle, var(--primary-glow), transparent 62%);
    opacity: .5;
    pointer-events: none;
}

/* Linhas de informação com ícone (Ambiente / Situação / Cadastrado em) */
.auth-rows {
    display: grid; gap: var(--sp-1);
    padding: var(--sp-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    margin-bottom: var(--sp-5);
}
.auth-row {
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
    padding: var(--sp-3);
    border-radius: var(--r-sm);
}
.auth-row + .auth-row { border-top: 1px solid var(--border-soft); }
.auth-row .k { display: flex; align-items: center; gap: var(--sp-3); font-size: .82rem; color: var(--text-2); }
.auth-row .k svg { width: 17px; height: 17px; color: var(--primary); flex-shrink: 0; }
.auth-row .v { font-size: .84rem; font-weight: var(--fw-semibold); color: var(--text); text-align: right; }

/* Botão principal das telas de estado: gradiente azul e seta que anda */
.btn-gradient {
    background: linear-gradient(100deg, var(--primary-700), var(--primary) 55%, var(--primary-600));
    color: var(--on-primary);
    border: 0;
    box-shadow: 0 10px 30px -12px var(--primary-glow);
}
.btn-gradient:hover:not(:disabled) {
    color: var(--on-primary);
    filter: brightness(1.06);
    box-shadow: 0 12px 34px -10px var(--primary-glow);
}
.btn-gradient .arrow { margin-left: auto; transition: transform var(--transition); }
.btn-gradient:hover .arrow { transform: translateX(3px); }
.btn-gradient.btn-block { justify-content: flex-start; gap: var(--sp-3); }

/* Caixa de recado ao pé da tela de estado */
.auth-note {
    display: flex; align-items: flex-start; gap: var(--sp-3);
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    font-size: .82rem; color: var(--text-2); line-height: 1.5;
    margin-top: var(--sp-4);
}
.auth-note svg { width: 17px; height: 17px; color: var(--primary); flex-shrink: 0; margin-top: 1px; }

.password-wrap { position: relative; }
.password-wrap .input { padding-right: 2.6rem; }
.password-toggle {
    position: absolute; right: .3rem; top: 50%; transform: translateY(-50%);
    background: none; border: 0; cursor: pointer;
    color: var(--text-faint); padding: .4rem;
}
.password-toggle:hover { color: var(--text); }

/* ---------------------------------------------------------------------
   22. Páginas de erro
   --------------------------------------------------------------------- */
.error-page {
    display: grid; place-items: center; min-height: 100vh; padding: 1.5rem;
}
.error-card {
    text-align: center; max-width: 460px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); padding: 2.5rem 2rem; box-shadow: var(--shadow);
}
.error-icon { font-size: 2.4rem; }
.error-code { font-size: 3.2rem; font-weight: 800; letter-spacing: -.05em; color: var(--primary); line-height: 1; margin: .3rem 0; }
.error-card h1 { font-size: 1.15rem; margin-bottom: .5rem; }
.error-card p { color: var(--text-muted); font-size: .875rem; }
.error-actions { display: flex; gap: .6rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   23. Instalador
   --------------------------------------------------------------------- */
.install-shell { max-width: 780px; margin: 0 auto; padding: 2.5rem 1.4rem 4rem; }
.install-steps { display: flex; gap: .4rem; margin-bottom: 1.8rem; flex-wrap: wrap; }
.install-step {
    flex: 1 1 120px;
    padding: .6rem .75rem;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: .78rem; color: var(--text-muted);
}
.install-step.active { border-color: var(--primary); background: var(--primary-soft); color: var(--text); font-weight: 600; }
.install-step.done { border-color: var(--success); color: var(--success); }
.install-step .n { font-weight: 700; margin-right: .3rem; }

.req-list { display: grid; gap: .1rem; }
.req-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .2rem; border-bottom: 1px solid var(--border-soft);
    font-size: .86rem;
}
.req-item:last-child { border-bottom: 0; }
.req-state { width: 20px; text-align: center; flex-shrink: 0; }
.req-ok { color: var(--success); }
.req-fail { color: var(--danger); }
.req-warn { color: var(--warning); }

/* ---------------------------------------------------------------------
   24. Responsivo
   --------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .main { margin-left: 0; }
    .sidebar-toggle { display: grid; }
    .content { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
    .topbar { padding: 0 var(--sp-4); }
    .impersonation-bar { padding: var(--sp-3) var(--sp-4); }
}

.sidebar-backdrop {
    position: fixed; inset: 0; z-index: 55;
    background: var(--overlay);
    display: none;
}
.sidebar-backdrop.open { display: block; }
@media (min-width: 1025px) { .sidebar-backdrop { display: none !important; } }

@media (max-width: 640px) {
    :root { --topbar-h: 60px; }
    body { font-size: 14px; }
    h1 { font-size: 1.3rem; }
    .grid-cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-3); }
    .stat { padding: var(--sp-4); }
    .stat-value { font-size: 1.4rem; }
    .card-body { padding: var(--sp-4); }
    .topbar-date, .topbar-user { display: none; }
    .filters { padding: .8rem .95rem; }
    .filters .field { flex: 1 1 100%; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }
    .flash-stack { top: auto; bottom: 1rem; right: 1rem; left: 1rem; width: auto; }
    .modal-foot { flex-direction: column-reverse; }
    .modal-foot .btn { width: 100%; }
}

@media print {
    .sidebar, .topbar, .page-actions, .filters, .pagination, .flash-stack { display: none !important; }
    .main { margin-left: 0; }
    body { background: #fff; color: #000; }
    .card { border-color: #ccc; box-shadow: none; }
}

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

/* =====================================================================
   25 · PLANOS E PAGAMENTO PIX
   ================================================================== */

.plan-grid {
    display: grid;
    gap: var(--sp-4);
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.plan-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    transition: border-color var(--transition), transform var(--transition);
}
.plan-card:hover { border-color: var(--border-strong); }

/* O plano contratado ganha a borda de destaque em vez de um selo
   colorido no meio da lista: marca sem competir com os outros. */
.plan-card.is-current {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 5%, var(--surface));
}

.plan-flag {
    position: absolute;
    top: calc(var(--sp-3) * -1);
    left: var(--sp-5);
    padding: 2px var(--sp-3);
    font-size: .7rem;
    font-weight: var(--fw-bold);
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--on-primary);
    background: var(--primary);
    border-radius: var(--r-full);
}

.plan-head { text-align: center; }
.plan-icon { font-size: 1.9rem; line-height: 1; display: block; }
.plan-name { font-size: 1.15rem; margin-top: var(--sp-2); }
.plan-tagline { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

.plan-price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 3px;
    padding: var(--sp-3) 0;
    border-block: 1px solid var(--border);
}
.plan-currency { font-size: .85rem; color: var(--text-2); }
.plan-amount { font-size: 1.9rem; font-weight: var(--fw-black); letter-spacing: -.03em; }
.plan-period { font-size: .8rem; color: var(--text-muted); }

.plan-credit {
    padding: var(--sp-3);
    font-size: .78rem;
    line-height: 1.45;
    color: var(--text-2);
    background: var(--success-soft);
    border-radius: var(--r-sm);
}
.plan-credit-total { display: block; margin-top: 2px; color: var(--success); font-weight: var(--fw-bold); }

.plan-features { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); flex: 1; }
.plan-features li {
    display: flex; align-items: flex-start; gap: var(--sp-2);
    font-size: .82rem; color: var(--text-2); line-height: 1.4;
}
.plan-check { color: var(--success); flex-shrink: 0; margin-top: 2px; }

.plan-foot { display: grid; gap: var(--sp-2); }
.plan-foot .hint { text-align: center; }
.w-full { width: 100%; justify-content: center; }

/* -------- QR do PIX -------- */
.pix-qr {
    width: 100%; max-width: 260px; height: auto;
    padding: var(--sp-3);
    background: #fff;              /* QR precisa de fundo claro para ler */
    border-radius: var(--r-md);
}
.pix-qr-empty {
    display: grid; place-items: center; gap: var(--sp-2);
    min-height: 200px; padding: var(--sp-5);
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: var(--r-md);
    font-size: .8rem;
}

@media (max-width: 640px) {
    .plan-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------
   Aviso de assinatura vencendo (últimos dias)

   Fica logo abaixo da topbar, em vermelho, e não é dispensável: o
   objetivo é que o cliente não descubra o vencimento só quando o painel
   fechar. Nos dois últimos dias o tom fecha e a barra pulsa devagar.
   --------------------------------------------------------------------- */
.subscription-bar {
    display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
    padding: var(--sp-3) var(--sp-6);
    background: linear-gradient(90deg, var(--danger-soft), transparent 70%);
    border-bottom: 1px solid var(--danger);
    color: var(--text);
    font-size: .85rem;
}
.subscription-bar svg { color: var(--danger); flex-shrink: 0; }
.subscription-bar strong { color: var(--danger); font-weight: var(--fw-bold); }
.subscription-bar .btn { margin-left: auto; }

/* Último dia (ou o próprio dia do vencimento): fundo cheio. */
.subscription-bar.is-critical {
    background: var(--danger);
    border-bottom-color: var(--danger);
    color: var(--on-primary);
    animation: subscription-pulse 2.4s ease-in-out infinite;
}
.subscription-bar.is-critical svg,
.subscription-bar.is-critical strong { color: var(--on-primary); }
.subscription-bar.is-critical .btn {
    background: var(--on-primary); color: var(--danger); border-color: transparent;
}

@keyframes subscription-pulse {
    0%, 100% { filter: brightness(1); }
    50%      { filter: brightness(1.12); }
}

@media (prefers-reduced-motion: reduce) {
    .subscription-bar.is-critical { animation: none; }
}

@media (max-width: 640px) {
    .subscription-bar { padding: var(--sp-3) var(--sp-4); font-size: .8rem; }
    .subscription-bar .btn { margin-left: 0; width: 100%; justify-content: center; }
}

/* ---------------------------------------------------------------------
   Vocações do Tibia

   Cada vocação ganha sua cor. Todas saem de tokens que já existem, então
   claro e escuro acompanham sozinhos — e o avatar continua com o mesmo
   formato dos outros, só o conteúdo muda.
   --------------------------------------------------------------------- */
.avatar.voc {
    background: var(--voc-soft, var(--surface-2));
    color: var(--voc-color, var(--text-2));
    border: 1px solid color-mix(in srgb, var(--voc-color, var(--border)) 28%, transparent);
}

.voc-knight   { --voc-color: var(--warning); --voc-soft: var(--warning-soft); }
.voc-paladin  { --voc-color: var(--success); --voc-soft: var(--success-soft); }
.voc-sorcerer { --voc-color: var(--danger);  --voc-soft: var(--danger-soft); }
.voc-druid    { --voc-color: var(--info);    --voc-soft: var(--info-soft); }
.voc-monk     { --voc-color: var(--gold);    --voc-soft: var(--gold-soft); }
.voc-none     { --voc-color: var(--text-muted); --voc-soft: var(--muted-soft); }

/* Prefixo do campo no formulário: mesma cor, sem a moldura do avatar. */
.input-prefix.voc {
    color: var(--voc-color, var(--text-muted));
    background: transparent;
    display: inline-flex;
    align-items: center;
}
