/* ============================================
   FOLHAS DO HÁBITO — layout.css v5
   Design profissional completo
   ============================================ */

:root {
    /* ── Paleta principal (verde padrão) ── */
    --fh-accent:       #4ade80;
    --fh-accent-dark:  #22c55e;
    --fh-accent-glow:  rgba(74,222,128,0.2);
    --fh-accent-soft:  rgba(74,222,128,0.1);
    --fh-border:       rgba(74,222,128,0.18);
    --fh-border-hover: rgba(74,222,128,0.5);
    --fh-text:         #e2e8f0;
    --fh-muted:        #94a3b8;
    --fh-dim:          #64748b;
    --fh-radius-lg:    24px;
    --fh-radius-md:    16px;
    --fh-radius-sm:    10px;
    --fh-radius:       16px;
    --fh-transition:   all 0.22s cubic-bezier(0.4,0,0.2,1);
    --fh-bg-card:      rgba(12,18,28,0.7);
    --fh-bg-card-hover:rgba(15,23,42,0.9);
    --fh-shadow:       0 4px 24px rgba(0,0,0,0.3);
    --fh-shadow-hover: 0 12px 40px rgba(0,0,0,0.45);

    /* ── Aliases para compatibilidade com dashboard.css ── */
    --accent:        var(--fh-accent);
    --accent-dark:   var(--fh-accent-dark);
    --accent-glow:   var(--fh-accent-glow);
    --accent-soft:   var(--fh-accent-soft);
    --border:        var(--fh-border);
    --border-hover:  var(--fh-border-hover);
    --text-main:     var(--fh-text);
    --text-muted:    var(--fh-muted);
    --text-dim:      var(--fh-dim);
    --bg-card:       var(--fh-bg-card);
    --bg-card-hover: var(--fh-bg-card-hover);
    --radius-lg:     var(--fh-radius-lg);
    --radius-md:     var(--fh-radius-md);
    --radius-sm:     var(--fh-radius-sm);
    --shadow-card:   var(--fh-shadow);
    --shadow-hover:  var(--fh-shadow-hover);
    --transition:    var(--fh-transition);
    --purple:        #8b5cf6;
    --purple-soft:   rgba(139,92,246,0.15);
}

* { margin:0; padding:0; box-sizing:border-box; }
html,body { min-height:100%; }
/* Guard de overflow: impede que um elemento mais largo que a tela expanda o
   viewport de layout (o que matava os @media mobile e "esticava" as ~30 telas
   que usam este shell). Sem isso, o reflow mobile nunca dispara. */
html, body { overflow-x: hidden; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--fh-text);
    min-height: 100vh;
    /* Fundo dinâmico responde ao tema */
    background:
        radial-gradient(ellipse at 15% 0%,   var(--fh-accent-glow) 0%, transparent 45%),
        radial-gradient(ellipse at 85% 100%,  var(--fh-accent-glow) 0%, transparent 45%),
        linear-gradient(160deg, #060a08 0%, #080d0a 50%, #050808 100%);
    transition: background 0.5s ease;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--fh-accent); text-decoration:none; transition: opacity 0.2s; }
a:hover { opacity:0.8; }

/* ── Shell ── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: 240px;
    flex: 0 0 240px;
    background: rgba(6,10,8,0.92);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--fh-border);
    padding: 18px 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
    position: sticky;
    top: 0;
    height: 100vh;         /* full-height: ocupa todo o vertical (itens novos preenchem o meio) */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.06) transparent;
    transition: border-color 0.3s ease;
}

/* ── Brand ── */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    text-decoration: none !important;
    padding: 4px 2px;
}

.brand-logo {
    width: 34px;
    height: 34px;
    min-width: 34px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 0 6px var(--fh-accent-glow));
    transition: filter 0.3s ease;
    background: transparent;
    border: none;
}

/* Folha SVG nos módulos (mesmo visual do dashboard) */
.brand-leaf-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 10px;
    background: transparent;
    border: none;
    transition: all 0.22s ease;
    flex-shrink: 0;
}

.brand-leaf-svg {
    color: var(--fh-accent);
    transition: color 0.3s ease, filter 0.3s ease;
    filter: drop-shadow(0 0 4px var(--fh-accent-glow));
    animation: leafSway 4s ease-in-out infinite;
}

@keyframes leafSway {
    0%, 100% { transform: rotate(0deg); }
    25%       { transform: rotate(4deg); }
    75%       { transform: rotate(-4deg); }
}

.brand:hover .brand-logo {
    filter: drop-shadow(0 0 12px var(--fh-accent));
}

.brand-info h1 {
    font-family: 'Lora', Georgia, serif;
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    background: linear-gradient(135deg, #f8fafc 0%, var(--fh-accent) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: background 0.3s ease;
}

.brand-info p {
    font-size: 0.68rem;
    color: var(--fh-dim);
    margin: 0;
}

.brand-sep {
    height: 1px;
    background: var(--fh-border);
    margin: 12px 0;
    transition: background 0.3s ease;
}

/* ── Card de perfil ── */
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--fh-accent-soft);
    border: 1px solid var(--fh-border);
    border-radius: 14px;
    margin-bottom: 12px;
    transition: var(--fh-transition);
}

.sidebar-profile:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--fh-accent);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--fh-accent), var(--fh-accent-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    color: #060a08;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--fh-accent-glow);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.profile-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.profile-name {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--fh-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-role {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--fh-accent);
    margin-top: 2px;
    transition: color 0.3s ease;
}

.profile-role::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--fh-accent);
    display: inline-block;
    transition: background 0.3s ease;
    box-shadow: 0 0 4px var(--fh-accent);
}

.profile-logout {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fh-dim);
    font-size: 0.8rem;
    transition: var(--fh-transition);
    background: transparent;
    text-decoration: none;
    flex-shrink: 0;
}

.profile-logout:hover {
    background: rgba(239,68,68,0.15);
    color: #fca5a5;
    opacity: 1;
}

/* ── Nav ── */
.menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 0 0 auto;   /* não estica: o seletor de cor cola embaixo do menu (mata o vão) */
}

.menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--fh-muted);
    text-decoration: none;
    transition: var(--fh-transition);
    font-weight: 500;
    font-size: 0.875rem;
    border: 1px solid transparent;
    white-space: nowrap;
}

.menu a:hover,
.menu a.active {
    color: var(--fh-accent);
    background: var(--fh-accent-soft);
    border-color: var(--fh-border);
    box-shadow: inset 3px 0 0 var(--fh-accent);
    opacity: 1;
}

/* ── Color picker ── */
.sidebar-color-picker {
    margin-top: auto;   /* ancora picker + rodapé no fundo; menu fica no topo */
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.sidebar-color-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--fh-dim);
    margin-bottom: 8px;
}

.sidebar-color-swatches {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer !important;
    pointer-events: auto !important;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    padding: 0;
}

.color-swatch:hover {
    border-color: rgba(255,255,255,0.7);
    transform: scale(1.25);
    box-shadow: 0 0 10px currentColor;
}

.color-swatch.active {
    border-color: #fff;
    transform: scale(1.15);
    box-shadow: 0 0 12px currentColor, 0 0 0 3px rgba(255,255,255,0.15);
}

/* ── Rodapé sidebar ── */
.sidebar-foot {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.04);
    font-size: 0.62rem;
    color: var(--fh-dim);
    text-align: center;
    line-height: 1.6;
}

/* ── Content ── */
.content {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
    min-width: 0;
}

/* ── Topbar dinâmica ── */
.topbar {
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.topbar-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.topbar-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--fh-text);
    margin-bottom: 3px;
}

.topbar-sub {
    font-size: 0.82rem;
    color: var(--fh-muted);
}

/* ── Alerts ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--fh-radius);
    margin-bottom: 20px;
    border-left: 4px solid;
    font-size: 0.9rem;
}

.alert-success { background: rgba(74,222,128,0.1);  border-left-color: #4ade80; color: #bbf7d0; }
.alert-warning  { background: rgba(251,191,36,0.1);  border-left-color: #fbbf24; color: #fef3c7; }
.alert-danger   { background: rgba(239,68,68,0.1);   border-left-color: #ef4444; color: #fecaca; }
.alert-info     { background: var(--fh-accent-soft); border-left-color: var(--fh-accent); color: #d1fae5; }

/* ── Painéis ── */
.panel {
    background: var(--fh-bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 20px;
    padding: 22px;
    margin-bottom: 20px;
    transition: border-color 0.3s ease;
}

.panel:hover { border-color: var(--fh-border); }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.panel-head h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--fh-text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-title h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--fh-text);
    margin: 0;
}

.muted, .helper {
    color: var(--fh-muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

/* ── Tabelas ── */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.table thead tr {
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

.table th {
    text-align: left;
    padding: 10px 14px;
    color: var(--fh-dim);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    white-space: nowrap;
}

.table td {
    padding: 13px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.035);
    color: var(--fh-text);
    vertical-align: middle;
}

.table tbody tr { transition: var(--fh-transition); }
.table tbody tr:hover { background: rgba(255,255,255,0.025); }
.table tbody tr:last-child td { border-bottom: none; }

/* ════════════════════════════════════════════════
   MOBILE — tabelas viram CARDS (.table-cards) — a "geladeira"
   Cada <tr> vira um cartão. Duas variantes:
     • .cards-rich → card desenhado de propósito (título grande,
       status no canto, número/barra, ações no rodapé) p/ telas-chave
       (Atributos, Missões). Sem rótulos.
     • (default)   → card rótulo:valor (log/lista: Histórico etc.).
   Escopado em .app-shell + .table-cards → só telas marcadas viram card;
   o resto segue intacto até a cascata. Sem scroll lateral; a função
   (Editar/Excluir/Status) que sumia fora da tela volta. Desktop intacto.
   ════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Cabeçalho da seção: título em cima, botão de ação cheio embaixo */
    .app-shell .section-title { flex-wrap: wrap; }
    .app-shell .section-title h3 { flex: 1 1 100%; }
    .app-shell .section-title .btn { flex: 1 1 auto; text-align: center; }

    /* Panel que segura os cards perde a chrome → cards flutuam e pulam */
    .app-shell .panel:has(.table-cards) {
        background: transparent;
        backdrop-filter: none;
        border: none;
        border-radius: 0;
        padding: 0;
        margin-bottom: 0;
    }

    /* ── Base: tabela/corpo/linha viram blocos; cada linha = card ── */
    .app-shell .table-cards,
    .app-shell .table-cards tbody { display: block; width: 100%; }
    .app-shell .table-cards thead { display: none; }
    .app-shell .table-cards tr {
        display: block;
        position: relative;
        background: var(--fh-bg-card);
        border: 1px solid var(--border);
        border-radius: 14px;
        padding: 16px;
        margin-bottom: 12px;
    }
    .app-shell .table-cards tbody tr:hover { background: var(--fh-bg-card); }
    .app-shell .table-cards tr:last-child { margin-bottom: 0; }
    .app-shell .table-cards td { border: none; }

    /* ── Variante LISTA (default): rótulo : valor por campo ── */
    .app-shell .table-cards:not(.cards-rich) td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 14px;
        padding: 7px 0;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }
    .app-shell .table-cards:not(.cards-rich) tr td:last-child { border-bottom: none; }
    .app-shell .table-cards:not(.cards-rich) td::before {
        content: attr(data-label);
        flex-shrink: 0;
        color: var(--fh-dim);
        font-size: 0.66rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    .app-shell .table-cards:not(.cards-rich) td:empty { display: none; }
    .app-shell .table-cards:not(.cards-rich) td > * { text-align: right; }

    /* ── Variante RICH: card desenhado, sem rótulos ── */
    .app-shell .table-cards.cards-rich td { display: block; padding: 0; }
    .app-shell .table-cards.cards-rich td:empty { display: none; }
    /* Título grande (folga à direita pro badge de status no canto) */
    .app-shell .cards-rich td[data-label="Atributo"],
    .app-shell .cards-rich td[data-label="Missão"] {
        font-size: 1.05rem;
        padding-right: 88px;
        margin-bottom: 8px;
    }
    /* Descrição (Atributos) */
    .app-shell .cards-rich td[data-label="Descrição"]:not(:empty) {
        font-size: 0.9rem;
        line-height: 1.5;
        margin-bottom: 12px;
    }
    /* Categorias (Missões) numa linha própria */
    .app-shell .cards-rich td[data-label="Categorias"] { margin-bottom: 10px; }
    /* Pontos + Progresso (Atributos) na mesma linha */
    .app-shell .cards-rich td[data-label="Pontos investidos"],
    .app-shell .cards-rich td[data-label="Progresso"] {
        display: inline-block;
        vertical-align: bottom;
    }
    .app-shell .cards-rich td[data-label="Pontos investidos"] { margin-right: 18px; }
    .app-shell .cards-rich td[data-label="Progresso"] { min-width: 130px; }
    /* Recompensa + Prioridade + Tipo (Missões) numa linha */
    .app-shell .cards-rich td[data-label="Recompensa"],
    .app-shell .cards-rich td[data-label="Prioridade"],
    .app-shell .cards-rich td[data-label="Tipo"] {
        display: inline-block;
        vertical-align: middle;
        margin-right: 12px;
    }
    /* Status = badge no canto superior direito do card */
    .app-shell .cards-rich td[data-label="Status"] {
        position: absolute;
        top: 16px;
        right: 16px;
    }

    /* ── Ações = rodapé do card, botões cheios (44px) — ambas variantes ── */
    .app-shell .table-cards td[data-label="Ações"] {
        display: block;
        margin-top: 14px;
        padding-top: 12px;
        border-top: 1px solid var(--border);
        border-bottom: none;
    }
    .app-shell .table-cards td[data-label="Ações"]::before { content: none; }
    .app-shell .table-cards td[data-label="Ações"] > div { display: flex; gap: 10px; }
    .app-shell .table-cards td[data-label="Ações"] .btn,
    .app-shell .table-cards td[data-label="Ações"] .btn-link { flex: 1; text-align: center; padding: 11px 12px; }
    .app-shell .table-cards td[data-label="Ações"] form { flex: 1; display: flex; }
    .app-shell .table-cards td[data-label="Ações"] form .btn,
    .app-shell .table-cards td[data-label="Ações"] form .btn-link { width: 100%; }
    /* Ação solta (sem wrapper <div>/<form>) ocupa a largura — ex.: Falhas, Conclusões */
    .app-shell .table-cards td[data-label="Ações"] > .btn,
    .app-shell .table-cards td[data-label="Ações"] > .btn-link { display: block; width: 100%; text-align: center; }

    /* Estado vazio ("Nenhuma falha registrada.") = mensagem centrada, sem rótulo */
    .app-shell .table-cards td.empty { display: block; text-align: center; padding: 10px 0; color: var(--fh-muted); }
    .app-shell .table-cards td.empty::before { content: none; }

    /* Conclusões: seleção em massa é desktop-only — esconde os checkboxes no card
       (o "selecionar todas" já vive no thead oculto); o Excluir individual segue.
       A barra de ação em massa quebra linha se aparecer, pra não estourar. */
    .app-shell .table-cards td.check-col { display: none; }
    .app-shell #bulkBar { flex-wrap: wrap; }
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 40px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.badge-critical { background: rgba(239,68,68,0.15);    color: #fca5a5;  border: 1px solid rgba(239,68,68,0.3); }
.badge-high     { background: rgba(251,146,60,0.15);   color: #fdba74;  border: 1px solid rgba(251,146,60,0.3); }
.badge-medium   { background: rgba(250,204,21,0.12);   color: #fde047;  border: 1px solid rgba(250,204,21,0.25); }
.badge-low      { background: rgba(148,163,184,0.12);  color: #cbd5e1;  border: 1px solid rgba(148,163,184,0.2); }
.badge-info     { background: var(--fh-accent-soft);   color: var(--fh-accent); border: 1px solid var(--fh-border); }
.badge-success  { background: rgba(74,222,128,0.12);   color: #86efac;  border: 1px solid rgba(74,222,128,0.25); }
.badge-danger   { background: rgba(239,68,68,0.12);    color: #fca5a5;  border: 1px solid rgba(239,68,68,0.2); }
.badge-warning  { background: rgba(251,191,36,0.12);   color: #fde68a;  border: 1px solid rgba(251,191,36,0.2); }
.badge-primary  { background: rgba(56,189,248,0.12);   color: #7dd3fc;  border: 1px solid rgba(56,189,248,0.2); }

/* ── Mini progress bar ── */
.mini-bar {
    background: rgba(255,255,255,0.07);
    border-radius: 60px;
    height: 5px;
    overflow: hidden;
    margin-top: 6px;
}

.mini-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fh-accent), var(--fh-accent-dark));
    border-radius: 60px;
    box-shadow: 0 0 6px var(--fh-accent-glow);
    transition: width 0.8s cubic-bezier(0.2,0.9,0.4,1.1), background 0.3s ease;
    min-width: 3px;
}

/* ── Botões ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--fh-transition);
    text-decoration: none;
    border: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--fh-accent);
    color: #060a08;
    box-shadow: 0 4px 14px var(--fh-accent-glow);
}

.btn-primary:hover {
    background: var(--fh-accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--fh-accent-glow);
    opacity: 1;
    color: #060a08;
}

.btn-secondary {
    background: rgba(255,255,255,0.07);
    color: var(--fh-text);
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.12);
    border-color: var(--fh-border);
    color: var(--fh-text);
    opacity: 1;
}

.btn-danger {
    background: rgba(239,68,68,0.15);
    color: #fca5a5;
    border: 1px solid rgba(239,68,68,0.2);
}

.btn-danger:hover {
    background: rgba(239,68,68,0.25);
    transform: translateY(-1px);
    opacity: 1;
}

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }

.btn-link {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 0.82rem;
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--fh-transition);
    font-weight: 600;
}

.btn-link:hover { background: rgba(239,68,68,0.12); }

/* ── Formulários ── */
.form-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
    gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 5px; }

.field label,
.field > label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--fh-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.field input,
.field select,
.field textarea,
input[type="number"],
input[type="date"],
select,
textarea {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--fh-text);
    font-size: 0.9rem;
    transition: var(--fh-transition);
    width: 100%;
    font-family: inherit;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--fh-accent);
    box-shadow: 0 0 0 3px var(--fh-accent-glow);
}

.field textarea,
textarea { min-height: 90px; resize: vertical; }

.actions {
    display: flex;
    gap: 10px;
    padding-top: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Cards de stats ── */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px,1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--fh-bg-card);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 18px;
    padding: 16px 18px;
    transition: var(--fh-transition);
}

.stat-card:hover {
    border-color: var(--fh-border);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.stat-card-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--fh-dim);
    margin-bottom: 8px;
    font-weight: 700;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--fh-accent);
    line-height: 1;
    margin-bottom: 4px;
    transition: color 0.3s ease;
}

.stat-card-sub {
    font-size: 0.75rem;
    color: var(--fh-muted);
}

/* ── Atributo card (Upar atributos) ── */
.attr-card {
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    padding: 14px 16px;
    transition: var(--fh-transition);
    margin-bottom: 8px;
}

.attr-card:hover {
    background: var(--fh-accent-soft);
    border-color: var(--fh-border);
}

.attr-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.attr-card-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--fh-text);
}

.attr-card-points {
    font-size: 0.78rem;
    color: var(--fh-muted);
    margin-top: 2px;
}

/* ── Rank card (Config de Classe) ── */
.rank-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 6px;
    transition: var(--fh-transition);
    border: 1px solid transparent;
}

.rank-row:hover {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.06);
}

.rank-row.current-rank {
    background: var(--fh-accent-soft);
    border-color: var(--fh-border);
    box-shadow: 0 0 16px var(--fh-accent-glow);
}

.rank-label {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rank-tier-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.rank-range {
    font-size: 0.82rem;
    color: var(--fh-muted);
    font-family: monospace;
}

/* ── Histórico ganho/distribuição ── */
.hist-ganho    { color: #86efac; font-weight: 700; }
.hist-dist     { color: #fca5a5; font-weight: 700; }
.hist-type-ganho { 
    background: rgba(74,222,128,0.1); 
    color: #86efac; 
    border: 1px solid rgba(74,222,128,0.2);
    padding: 2px 10px;
    border-radius: 40px;
    font-size: 0.72rem;
    font-weight: 700;
}
.hist-type-dist { 
    background: rgba(239,68,68,0.1); 
    color: #fca5a5; 
    border: 1px solid rgba(239,68,68,0.2);
    padding: 2px 10px;
    border-radius: 40px;
    font-size: 0.72rem;
    font-weight: 700;
}

/* ── Grid 2 cols ── */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

/* ════════════════════════════════════════════════
   MOBILE — gaveta off-canvas nos MÓDULOS (espelho do dashboard)
   Tudo escopado em .app-shell pra NÃO tocar o dashboard (que usa
   .app-shell-dashboard + regras próprias no dashboard.css).
   Substitui a antiga "trilha de 60px" pela gaveta consistente,
   reusando o mobile_nav.js genérico ([data-drawer*]).
   Sem aurora/partículas (são só do dashboard) e sem workaround
   novo de GPU — o flash cinza segue pendente de teste em outro aparelho.
   ════════════════════════════════════════════════ */

/* Exclusivos de mobile — escondidos no desktop */
.app-shell .mobile-topbar,
.app-shell .drawer-overlay,
.app-shell .drawer-close { display: none; }

@media (max-width: 768px) {
    /* Barra superior fixa e slim (hambúrguer + marca) */
    .app-shell .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 56px;
        padding: 0 12px;
        padding-top: env(safe-area-inset-top, 0px);
        background: #060a08;
        border-bottom: 1px solid var(--border);
        z-index: 200;
    }
    .app-shell .mt-hamburger {
        display: inline-flex;
        align-items: center; justify-content: center;
        width: 44px; height: 44px; min-width: 44px;
        border-radius: 12px;
        background: transparent;
        border: 1px solid var(--border);
        color: var(--accent);
        cursor: pointer; padding: 0;
        transition: background 0.2s, border-color 0.2s;
    }
    .app-shell .mt-hamburger:active { background: var(--accent-soft); border-color: var(--border-hover); }
    .app-shell .mt-brand {
        display: flex; align-items: center; gap: 8px;
        font-family: 'Lora', Georgia, serif;
        font-weight: 700; font-size: 1rem; color: #f8fafc;
        text-decoration: none;
    }
    .app-shell .mt-brand svg { color: var(--accent); flex-shrink: 0; }

    /* Shell vira coluna; sidebar sai do fluxo e vira gaveta */
    .app-shell { flex-direction: column; }
    .app-shell .sidebar {
        position: fixed;
        top: 0; left: 0;
        width: 82vw; max-width: 320px;
        height: 100vh; height: 100dvh;
        margin: 0;
        padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
        border-radius: 0;
        border-right: 1px solid var(--border);
        transform: translateX(-100%);
        transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
        z-index: 300;
        overflow-y: auto;
        /* MATA o bounce elástico da gaveta (não só o encadeamento) — senão o gesto
           "arrasta-solta-arrasta" revela o cinza atrás. */
        overscroll-behavior: none;
        /* fundo opaco + sem blur: necessário pra gaveta legível */
        background: #060a08;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    body.drawer-open .app-shell .sidebar { transform: translateX(0); }

    /* Links da gaveta: rótulo cheio + alvo de toque confortável (não a trilha).
       Sem escopo .app-shell → vale pros DOIS sidebars (dashboard e módulos). */
    .menu a { padding: 13px 14px; font-size: 0.95rem; }
    .menu a:active { background: var(--accent-soft); }

    /* Gaveta mostra perfil/marca/rodapé/picker completos */
    .app-shell .brand-info,
    .app-shell .sidebar-foot,
    .app-shell .profile-info,
    .app-shell .sidebar-color-picker { display: block; }
    .app-shell .profile-logout { display: flex; }

    /* Overlay escuro atrás da gaveta */
    .app-shell .drawer-overlay {
        display: block;
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.55);
        opacity: 0; pointer-events: none;
        transition: opacity 0.32s ease;
        z-index: 250;
    }
    body.drawer-open .app-shell .drawer-overlay { opacity: 1; pointer-events: auto; }
    body.drawer-open { overflow: hidden; }

    /* Botão de fechar dentro da gaveta */
    .app-shell .drawer-close {
        display: inline-flex;
        align-items: center; justify-content: center;
        position: absolute; top: 12px; right: 12px;
        width: 40px; height: 40px;
        border-radius: 10px;
        background: rgba(255,255,255,0.06);
        border: 1px solid var(--border);
        color: var(--text-muted);
        font-size: 1.5rem; line-height: 1;
        cursor: pointer; padding: 0; z-index: 2;
    }
    .app-shell .drawer-close:active { background: rgba(255,255,255,0.12); }

    /* Conteúdo abre espaço pro topbar fixo; título mais compacto */
    .app-shell .content { padding: 72px 16px 16px; }
    .app-shell .topbar-title { font-size: 1.2rem; }
}

/* ═══════════════════════════════════════════
   MOBILE HORIZONTAL — trilho lateral + shell dos MÓDULOS (compartilhado)
   Gêmeo do bloco do dashboard.css, porém pro shell .app-shell dos módulos.
   O .landscape-rail (markup no header.php) substitui a sidebar/topbar só no
   celular DEITADO; a DENSIDADE do conteúdo de cada página vive no <style> dela.
   O dashboard usa .app-shell-dashboard → as regras .app-shell daqui não o tocam;
   as regras de .landscape-rail são idênticas às do dashboard.css (sem conflito).
   ═══════════════════════════════════════════ */
.landscape-rail { display: none; }

@media (orientation: landscape) and (max-height: 600px) {
    /* 🔑 DESTRAVA O STICKY: html/body têm `overflow-x:hidden` (computa
       `overflow:hidden auto`), que cria um scroll-container e MATA todo
       `position:sticky` interno (o trilho E o radar rolavam junto com a página).
       `overflow-x:clip` clipa o horizontal SEM virar scroll-container → sticky volta.
       !important porque o dashboard re-seta `body{overflow-x:hidden}` depois na cascata. */
    html, body { overflow-x: clip !important; }

    /* Shell dos módulos vira linha; trilho no lugar da sidebar/topbar.
       align-items:flex-start é OBRIGATÓRIO: sem ele o default `stretch` estica o
       trilho à altura do CONTEÚDO inteiro e o `position:sticky` para de pinar
       (o trilho rolava junto com a página). */
    .app-shell { flex-direction: row; gap: 0; align-items: flex-start; }
    .app-shell > .sidebar { display: none; }
    .app-shell .mobile-topbar { display: none !important; }
    .app-shell .content { padding: 10px 14px; }
    .app-shell .topbar { margin-bottom: 6px; }
    .app-shell .topbar-title { font-size: 1.05rem; line-height: 1.15; }
    .app-shell .topbar-sub { font-size: 0.72rem; }
    body { padding: 0 !important; }
    .music-bubble { display: none !important; }

    /* Trilho lateral (mesmo visual do dashboard).
       overflow-y:auto + overscroll-behavior:contain → vira scroll PRÓPRIO
       (não rola junto com a página) quando há itens demais (admin=9) numa tela
       baixa; itens compactos pra os 9 caberem em ~320px sem precisar rolar. */
    .landscape-rail {
        display: flex; flex-direction: column; align-items: stretch;
        position: sticky; top: 0; align-self: flex-start;
        flex: 0 0 56px; width: 56px; height: 100dvh;
        overflow-y: auto; overscroll-behavior: contain;
        scrollbar-width: none;
        background: #060a08;
        border-right: 1px solid var(--border, rgba(255,255,255,0.08));
        padding: 8px 0 calc(env(safe-area-inset-bottom, 0px) + 7px);
        padding-left: env(safe-area-inset-left, 0px);
        z-index: 50;
    }
    .landscape-rail::-webkit-scrollbar { display: none; }
    .lr-brand { flex: none; text-align: center; color: var(--accent, #4ade80); font-size: 17px; line-height: 1; margin-bottom: 4px; text-decoration: none; }
    .lr-item { flex: none; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 0; text-decoration: none; color: rgba(255,255,255,0.5); transition: color 0.18s ease; }
    .lr-item:active, .lr-item.is-active { color: var(--accent, #4ade80); }
    .lr-ico { font-size: 17px; line-height: 1; }
    .lr-lbl { font-size: 7.5px; letter-spacing: 0.2px; }
    .lr-foot { margin-top: auto; padding-top: 7px; border-top: 1px solid rgba(255,255,255,0.07); }
    .lr-avatar { flex: none; margin-top: auto; padding-top: 7px; width: 28px; height: 28px; align-self: center; border-radius: 9px; background: linear-gradient(135deg, #4ade80, #a78bfa); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #06210f; text-decoration: none; box-sizing: content-box; }
}
