:root {
    --brand:       #0d6efd;
    --brand-dark:  #0a58ca;
    --brand-soft:  #e7f1ff;
    --water:       #0dcaf0;
    --success:     #198754;
    --warning:     #ffc107;
    --danger:      #dc3545;
    --bg:          #f5f7fb;
    --ink:         #1f2937;
    --muted:       #6c757d;
    --radius:      14px;
    --shadow-sm:   0 1px 3px rgba(0,0,0,.05);
    --shadow-md:   0 6px 18px rgba(13, 110, 253, .08);
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

.body-app {
    padding-bottom: 80px;
}

/* ========= NAVBAR ========= */
.navbar {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
}
.navbar-brand { font-weight: 700; letter-spacing: .2px; }
.navbar-brand i { font-size: 1.3em; color: var(--water); }
.nav-link { color: rgba(255,255,255,.85) !important; font-weight: 500; }
.nav-link:hover, .nav-link.active { color: #fff !important; }
.nav-link i { margin-right: .3em; }

/* ========= PAGE ========= */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--ink);
}

.card {
    border: 1px solid rgba(0,0,0,.06);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background-color: #fff;
    border-bottom: 1px solid rgba(0,0,0,.06);
    font-weight: 500;
    border-top-left-radius: var(--radius) !important;
    border-top-right-radius: var(--radius) !important;
}

.btn { border-radius: 10px; font-weight: 500; }
.btn-lg { padding: .75rem 1.25rem; }
.btn-primary, .btn-primary:focus {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    border: none;
}
.btn-primary:hover { background: var(--brand-dark); }

.form-control, .form-select {
    border-radius: 10px;
    border-color: rgba(0,0,0,.1);
    padding: .55rem .75rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .15);
}

/* ========= STATS ========= */
.stat {
    padding: 1.25rem;
    border-radius: var(--radius);
    border: none;
    position: relative;
    overflow: hidden;
    color: #fff;
    box-shadow: var(--shadow-md);
}
.stat-icon {
    position: absolute; right: 14px; top: 14px;
    font-size: 2.2rem; opacity: .25;
}
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .85rem; opacity: .9; margin-top: .25rem; }

.stat-blue   { background: linear-gradient(135deg, #0d6efd, #4dabff); }
.stat-cyan   { background: linear-gradient(135deg, #0dcaf0, #5ad5ef); }
.stat-yellow { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.stat-green  { background: linear-gradient(135deg, #16a34a, #4ade80); }

/* ========= AUTH ========= */
.body-auth {
    background: linear-gradient(135deg, #0d6efd 0%, #0dcaf0 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}
.body-auth footer {
    color: rgba(255, 255, 255, .8) !important;
    padding: 1.5rem 0 .5rem;
    flex-shrink: 0;
}
.footer-credit {
    color: inherit;
    text-decoration: none;
    font-weight: 500;
    opacity: .85;
    transition: opacity .15s ease;
}
.footer-credit:hover {
    opacity: 1;
    text-decoration: underline;
}
.body-auth .footer-credit {
    color: #fff !important;
}
.auth-main {
    flex: 1 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 2rem;
    max-width: 460px;
    margin: 0 auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.auth-brand { text-align: center; margin-bottom: 1.75rem; }
.auth-logo {
    max-width: 85%;
    height: auto;
    max-height: 120px;
    display: block;
    margin: 0 auto;
}
.brand-logo {
    width: 72px; height: 72px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, var(--brand), var(--water));
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 2rem;
    box-shadow: 0 10px 25px rgba(13,110,253,.25);
}
.auth-brand h1 { font-size: 1.3rem; margin: 0 0 .25rem; }
.auth-brand p { color: var(--muted); font-size: .9rem; margin: 0; }
.auth-form .form-label { font-size: .9rem; font-weight: 500; margin-bottom: .35rem; }

/* Card Equipe no login */
.equipe-card {
    max-width: 460px;
    margin: 0 auto;
    background: rgba(255,255,255,.95);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.15);
}
.equipe-titulo {
    font-size: .85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--brand-dark);
    margin-bottom: .75rem;
}
.equipe-membro {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: .55rem 0;
    border-bottom: 1px solid rgba(0,0,0,.06);
}
.equipe-membro:last-child { border-bottom: none; }
.equipe-icon {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
}
.equipe-info { flex: 1; min-width: 0; }
.equipe-papel {
    font-size: .7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .3px;
    font-weight: 600;
}
.equipe-nome {
    font-size: .95rem;
    line-height: 1.2;
    word-break: break-word;
}
.equipe-wa {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: #25D366;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
    font-size: 1.05rem;
}
.equipe-wa:hover { background: #1fb557; color: #fff; }

/* ========= ONBOARDING (BOAS-VINDAS) ========= */
.onboarding-card {
    max-width: 520px;
}
.onboarding-form .ob-step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 18px 0;
    border-bottom: 1px solid rgba(0,0,0,.06);
}
.onboarding-form .ob-step:last-of-type {
    border-bottom: none;
}
.onboarding-form .ob-number {
    flex-shrink: 0;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    box-shadow: 0 4px 10px rgba(13,110,253,.25);
}
.onboarding-form .ob-content {
    flex: 1;
    min-width: 0;
}
.onboarding-form .ob-hint {
    font-size: .8rem;
    color: var(--muted);
    margin-top: .35rem;
}
.onboarding-form .ob-hint code {
    background: #f1f3f5;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: .85em;
    color: #495057;
}
.onboarding-form .form-control-lg {
    font-size: 1.1rem;
    padding: .7rem .9rem;
}
.onboarding-form .btn-lg {
    font-size: 1.1rem;
    padding: .9rem 1rem;
}
@media (max-width: 575.98px) {
    .onboarding-card { padding: 1.5rem !important; }
    .onboarding-form .ob-number { width: 32px; height: 32px; font-size: .95rem; }
}

/* ========= USER CONTA ATUAL ========= */
.conta-atual {
    border: 2px solid var(--brand);
    background: linear-gradient(145deg, #fff 0%, var(--brand-soft) 100%);
}
.valor-grande {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.5px;
}

/* ========= COMUNICADOS ========= */
.comunicado-card { border-left: 4px solid var(--brand); }
.comunicado-card.tipo-raio { border-left-color: var(--warning); }
.comunicado-card.tipo-urgente { border-left-color: var(--danger); }
.comunicado-card.tipo-ata { border-left-color: #6c757d; }
.comunicado-card.tipo-aviso { border-left-color: var(--brand); }

.badge-tipo-aviso   { background: var(--brand-soft); color: var(--brand-dark); }
.badge-tipo-raio    { background: #fff4d6; color: #856404; }
.badge-tipo-urgente { background: #f8d7da; color: #842029; }
.badge-tipo-ata     { background: #e9ecef; color: #495057; }
[class^="badge-tipo-"] { padding: .3em .6em; font-size: .75rem; font-weight: 600; border-radius: 6px; }

/* ========= MOBILE TAB BAR ========= */
.mobile-tabbar {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,.08);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: .3rem 0 calc(.3rem + env(safe-area-inset-bottom));
    z-index: 1020;
    box-shadow: 0 -4px 20px rgba(0,0,0,.05);
}
.mobile-tabbar .tab {
    display: flex; flex-direction: column; align-items: center;
    padding: .4rem 0;
    text-decoration: none;
    color: var(--muted);
    font-size: .7rem;
    gap: .15rem;
}
.mobile-tabbar .tab i { font-size: 1.25rem; }
.mobile-tabbar .tab:active { color: var(--brand); }

/* ========= VOTAÇÃO + FÓRUM ========= */
.btn-vote {
    min-height: 96px;
    padding: 1rem .5rem;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid transparent;
    border-radius: var(--radius);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
    transition: all .15s ease;
    line-height: 1.1;
    text-align: center;
    white-space: normal;
}
.btn-vote i { font-size: 1.6rem; }
.btn-vote > div { font-size: 1rem; }
.btn-vote small {
    font-weight: 500;
    font-size: .7rem;
    opacity: .9;
    display: block;
}
.btn-vote-yes {
    background: #e8f5e9;
    color: #2e7d32;
    border-color: #a5d6a7;
}
.btn-vote-yes:hover, .btn-vote-yes.active {
    background: #2e7d32;
    color: #fff;
    border-color: #1b5e20;
}
.btn-vote-no {
    background: #ffebee;
    color: #c62828;
    border-color: #ef9a9a;
}
.btn-vote-no:hover, .btn-vote-no.active {
    background: #c62828;
    color: #fff;
    border-color: #8e0000;
}

.vote-bar {
    height: 8px;
    background: #fee2e2;
    border-radius: 4px;
    overflow: hidden;
}
.vote-bar-aprova {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #16a34a);
    transition: width .3s ease;
}
.vote-bar-large {
    height: 28px;
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    background: #e5e7eb;
}
.vote-bar-large .vote-bar-aprova {
    background: linear-gradient(90deg, #4ade80, #16a34a);
    min-width: 0;
}
.vote-bar-large .vote-bar-reprova {
    background: linear-gradient(90deg, #f87171, #dc2626);
    min-width: 0;
}
.vote-summary { padding: .25rem 0; }

.vote-legend {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: .5rem;
    margin-top: .5rem;
    font-size: .85rem;
}
.vote-legend > :first-child { text-align: left; }
.vote-legend > :nth-child(2) { text-align: center; }
.vote-legend > :last-child { text-align: right; }

/* Comentários */
.comunicado-mensagem {
    font-size: 1.05rem;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.comunicado-preview {
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.comentarios-lista {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.comentario-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.comentario-avatar {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
}
.comentario-body {
    flex: 1;
    min-width: 0;
    background: #f8f9fa;
    padding: .65rem .85rem;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,.05);
}
.comentario-header {
    margin-bottom: .25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .25rem .5rem;
}
.comentario-header .float-end { margin-left: auto; }
.comentario-mensagem {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.5;
}

/* Responsividade */
@media (max-width: 575.98px) {
    .btn-vote { min-height: 86px; padding: .8rem .4rem; }
    .btn-vote i { font-size: 1.4rem; }
    .btn-vote > div { font-size: .95rem; }
    .comentario-avatar { width: 34px; height: 34px; font-size: .9rem; }
    .comentario-body { padding: .55rem .75rem; }
    .vote-legend { grid-template-columns: 1fr; gap: .15rem; text-align: center !important; }
    .vote-legend > :first-child,
    .vote-legend > :last-child { text-align: center !important; }
    .vote-bar-large { height: 24px; }
    .comunicado-mensagem { font-size: 1rem; }
}

/* ========= WHATSAPP FLOATING BUTTON ========= */
.wa-float {
    position: fixed;
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    width: 56px; height: 56px;
    border-radius: 50%;
    background: #25D366;
    color: #fff !important;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.75rem;
    box-shadow: 0 6px 16px rgba(37,211,102,.45);
    z-index: 1030;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}
.wa-float:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 22px rgba(37,211,102,.55);
    color: #fff;
}
.wa-float.wa-above-tabbar {
    bottom: calc(88px + env(safe-area-inset-bottom));
}
@media (min-width: 992px) {
    .wa-float.wa-above-tabbar { bottom: 20px; }
}

/* ========= TABLES ========= */
.table > thead { font-size: .85rem; }
.table code { font-size: .85rem; background: #f1f3f5; padding: 1px 6px; border-radius: 4px; }

/* Olhinho para mostrar/ocultar senha */
.password-wrapper {
    position: relative;
    display: block;
}
.password-wrapper input {
    padding-right: 2.75rem !important;
}
.password-toggle {
    position: absolute;
    top: 50%;
    right: .25rem;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--muted);
    padding: .35rem .6rem;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    border-radius: 8px;
    transition: color .15s ease, background .15s ease;
}
.password-toggle:hover {
    color: var(--brand);
    background: var(--brand-soft);
}
.password-toggle:focus {
    outline: none;
    color: var(--brand);
}

/* Cabeçalho ordenável */
.table thead th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: relative;
    transition: background-color .15s ease;
}
.table thead th.sortable:hover {
    background-color: #e9ecef;
}
.table thead th.sortable .sort-icon {
    margin-left: .25rem;
    font-size: .75em;
    opacity: .7;
}
.table thead th.sort-active {
    background-color: #dde7ff !important;
    color: var(--brand-dark);
}

/* ========= UTIL ========= */
@media (max-width: 576px) {
    .page-title { font-size: 1.25rem; }
    .valor-grande { font-size: 2rem; }
    .stat-value { font-size: 1.5rem; }
    .card-body { padding: 1rem; }
}

/* nav collapse on mobile: keep spacing */
@media (max-width: 991.98px) {
    .navbar-collapse { padding-top: .75rem; }
    .nav-link { padding: .6rem .25rem; }
}
