:root {
    --ink: #251106;
    --navy: #1a0c06;
    --navy-deep: #140905;
    --teal: #9f3710;
    --gold: #d9942f;
    --sand: #fbf3e8;
    --paper: #fffdf9;
    --line: #ead6bf;
    --muted: #6a5346;
    --danger: #9b2c2c;
    --ok: #2f6d4f;
    --sidebar: 260px;
}

* { box-sizing: border-box; }

html, body {
    min-height: 100%;
}

body.app-body {
    margin: 0;
    color: var(--ink);
    background: var(--sand);
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
}

a { color: var(--teal); }

.brand-mark {
    font-family: "Libre Baskerville", Georgia, serif;
    letter-spacing: 0.02em;
}

.auth-shell,
.platform-shell,
.error-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(circle at top left, rgba(217, 148, 47, 0.22), transparent 32%),
        linear-gradient(160deg, #140905 0%, #251106 48%, #35180c 100%);
}

.auth-card,
.platform-card,
.error-card {
    width: min(520px, 100%);
    background: var(--paper);
    border-radius: 18px;
    padding: 2.2rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.platform-card { width: min(760px, 100%); }

.eyebrow {
    color: var(--gold);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
    min-height: 100vh;
    align-items: start;
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    max-height: 100vh;
    background: var(--navy-deep);
    color: #f3efe6;
    padding: 1.4rem 1rem;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.igreja-sidebar,
.admin-sidebar {
    min-height: 100vh;
}

.igreja-nav {
    padding-bottom: 1.5rem;
}

.igreja-nav-label {
    margin: 1rem 0.85rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #e0c48a;
}

.igreja-offcanvas {
    background: var(--navy-deep);
    color: #f3efe6;
    width: min(100%, 280px);
}

.igreja-offcanvas .btn-close {
    filter: invert(1);
}

.sidebar a {
    color: inherit;
    text-decoration: none;
}

.sidebar .brand {
    display: block;
    padding: 0.4rem 0.8rem 1.4rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 1rem;
}

.sidebar .brand-lockup {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.sidebar .brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: contain;
    background: #fbf3e8;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.sidebar .brand-mark {
    display: block;
    font-size: 1.15rem;
}

.sidebar .brand small {
    display: block;
    margin-top: 0.15rem;
    color: #e0c48a;
    font-size: 0.82rem;
}

.auth-logo {
    text-align: center;
}

.auth-logo img {
    width: min(100%, 280px);
    height: auto;
    border-radius: 0;
    object-fit: contain;
    box-shadow: none;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    color: #f4ead8;
    margin-bottom: 0.25rem;
    border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar .nav-link:hover {
    background: rgba(217, 148, 47, 0.16);
    color: #fbf3e8;
}

.sidebar .nav-link.active,
.igreja-offcanvas .nav-link.active,
.admin-offcanvas .nav-link.active {
    background: rgba(217, 148, 47, 0.28);
    color: #fff;
    border-left-color: #e0c48a;
    font-weight: 600;
}

.igreja-offcanvas .nav-link,
.admin-offcanvas .nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    color: #f4ead8;
    margin-bottom: 0.25rem;
    border-left: 3px solid transparent;
    text-decoration: none;
}

.igreja-offcanvas .nav-link:hover,
.admin-offcanvas .nav-link:hover {
    background: rgba(217, 148, 47, 0.16);
    color: #fbf3e8;
}

.main {
    min-width: 0;
}

.topbar {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 0.9rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.user-menu {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    max-width: 15rem;
    height: 2.4rem;
    padding: 0 0.65rem 0 0.25rem;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--navy);
    border-radius: 999px;
    font: inherit;
    cursor: pointer;
}

.user-menu:hover,
.user-menu:focus-visible,
.user-menu[aria-expanded="true"] {
    background: var(--sand);
    border-color: var(--gold);
}

.user-menu-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: var(--navy);
    color: var(--sand);
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-menu-meta {
    display: none;
    min-width: 0;
    text-align: left;
    line-height: 1.15;
}

.user-menu-meta strong,
.user-menu-meta small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-meta strong {
    font-size: 0.82rem;
}

.user-menu-meta small {
    color: var(--muted);
    font-size: 0.68rem;
}

.user-menu .bi-chevron-down {
    font-size: 0.7rem;
    color: var(--muted);
}

@media (min-width: 768px) {
    .user-menu-meta {
        display: block;
    }
}

.content {
    padding: 1.5rem;
}

.page-title {
    font-family: "Libre Baskerville", Georgia, serif;
    margin-bottom: 0.25rem;
}

.card-ek {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(26, 12, 6, 0.04);
}

.stat {
    padding: 1.1rem 1.2rem;
}

.stat .label {
    color: var(--muted);
    font-size: 0.86rem;
}

.stat .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--navy);
}

.table thead th {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.btn-gold {
    background: var(--gold);
    border-color: var(--gold);
    color: #fff;
}

.btn-gold:hover {
    background: #c6892e;
    border-color: #c6892e;
    color: #1a0c06;
}

.btn-navy {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
}

.btn-navy:hover {
    background: #d9942f;
    border-color: #d9942f;
    color: #1a0c06;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}

.ek-hero {
    position: relative;
    padding: 1.3rem 1.5rem;
    border-radius: 20px;
    color: #fff;
    background:
        radial-gradient(circle at calc(100% - 50px) 50px, rgba(217, 148, 47, 0.35), transparent 110px),
        linear-gradient(135deg, #1a0c06 0%, #3a1a0c 55%, #9f3710 130%);
}

.ek-hero-corpo {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.ek-hero-texto,
.ek-hero-corpo > div:first-child { min-width: 0; flex: 1 1 22rem; }
.ek-hero-corpo > div:not(:first-child) { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.ek-hero .page-title {
    font-family: "Libre Baskerville", Georgia, serif;
    font-size: 1.65rem;
    color: #fff;
    margin: 0.15rem 0 0.2rem;
}

.ek-hero .text-muted,
.ek-hero .text-secondary { color: rgba(255, 255, 255, 0.72) !important; }
.ek-hero a:not(.btn):not(.dropdown-item) { color: #f0c27a; }
.ek-hero a.small.text-muted {
    display: inline-block;
    color: #f0c27a !important;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
}
.ek-hero .dropdown-menu { color: var(--ink); }
.ek-hero .dropdown-menu .text-muted { color: var(--muted) !important; }

.ek-hero .btn { border-radius: 999px; }
.ek-hero .btn-gold,
.ek-hero .btn-navy,
.ek-hero .btn-primary,
.ek-hero .btn-dark,
.ek-hero .btn-success {
    background: #fff;
    border-color: #fff;
    color: var(--navy);
    font-weight: 600;
}
.ek-hero .btn-gold:hover,
.ek-hero .btn-navy:hover,
.ek-hero .btn-primary:hover,
.ek-hero .btn-dark:hover,
.ek-hero .btn-success:hover { background: #f0c27a; border-color: #f0c27a; color: var(--navy); }
.ek-hero .btn-outline-secondary,
.ek-hero .btn-outline-dark,
.ek-hero .btn-outline-primary,
.ek-hero .btn-outline-success,
.ek-hero .btn-light:not(.fw-semibold),
.ek-hero .btn-outline-light {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
}
.ek-hero .btn-outline-secondary:hover,
.ek-hero .btn-outline-dark:hover,
.ek-hero .btn-outline-primary:hover,
.ek-hero .btn-outline-success:hover,
.ek-hero .btn-light:not(.fw-semibold):hover,
.ek-hero .btn-outline-light:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.6); color: #fff; }
.ek-hero .btn-outline-danger,
.ek-hero .btn-outline-warning { background: transparent; border-color: rgba(255, 180, 168, 0.55); color: #ffcabf; }
.ek-hero .btn-outline-danger:hover,
.ek-hero .btn-outline-warning:hover { background: rgba(155, 44, 44, 0.45); color: #fff; }
.ek-hero .btn-danger { border-color: transparent; }

.ek-eyebrow-sep { margin: 0 0.45rem; opacity: 0.6; }

.ek-eyebrow {
    color: #f0c27a;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.ek-eyebrow a { color: inherit; text-decoration: none; }
.ek-eyebrow a:hover { color: #fff; }

.ek-hero h1 {
    font-family: "Libre Baskerville", Georgia, serif;
    font-size: 1.65rem;
    margin: 0.15rem 0 0.2rem;
}

.ek-hero p { color: rgba(255, 255, 255, 0.72); margin: 0; max-width: 60rem; }
.ek-hero p a { color: #f0c27a; }
.ek-hero p code { color: #f0c27a; background: rgba(255, 255, 255, 0.08); padding: 0 0.25rem; border-radius: 4px; }

.ek-hero-accoes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ek-hero .btn-light,
.ek-hero .btn-outline-light { border-radius: 999px; }
.ek-hero .btn-outline-light { border-color: rgba(255, 255, 255, 0.35); }

.content {
    --bs-border-color: var(--line);
    --bs-border-radius: 10px;
}

:where(.content) .form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

:where(.content) .form-control,
:where(.content) .form-select {
    background-color: #fff;
}

:where(.content) .form-control:focus,
:where(.content) .form-select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 0.2rem rgba(217, 148, 47, 0.18);
}

:where(.content) .form-control:disabled,
:where(.content) .form-select:disabled,
:where(.content) .form-control[readonly] {
    background-color: #f6efe6;
}

:where(.content) .form-check-input:checked {
    background-color: var(--teal);
    border-color: var(--teal);
}

:where(.content) .form-check-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 0.2rem rgba(217, 148, 47, 0.18);
}

:where(.content) .form-text { color: var(--muted); font-size: 0.8rem; }
:where(.content) .input-group-text { background: #fbf6ef; color: var(--muted); }

.form-categoria { padding: 1.2rem 1.3rem !important; }

.form-categoria-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 0.2rem;
}

.form-categoria-title::before {
    content: "";
    width: 4px;
    height: 1.05rem;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--gold), var(--teal));
    flex-shrink: 0;
}

.form-categoria-help {
    color: var(--muted);
    font-size: 0.84rem;
    margin-bottom: 1rem;
}

.form-categoria-title + .row,
.form-categoria-title + div { margin-top: 0.8rem; }

.ek-form-accoes {
    position: sticky;
    bottom: 0.75rem;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 253, 249, 0.96);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(26, 12, 6, 0.1);
    backdrop-filter: blur(6px);
}

.ek-form-accoes .btn { border-radius: 999px; padding-left: 1.1rem; padding-right: 1.1rem; }
.ek-form-accoes .btn[type="submit"] { font-weight: 600; order: 2; }
.ek-form-accoes.justify-content-between .btn[type="submit"] { order: 0; }

.card-ek > form > .ek-form-accoes,
.card-ek > .ek-form-accoes {
    margin: 1.5rem -1.5rem -1.5rem;
    border-width: 1px 0 0;
    border-radius: 0 0 16px 16px;
    box-shadow: none;
}

.membro-foto {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    background: var(--navy);
    color: #fbf3e8;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    border: 1px solid var(--line);
}

.membro-foto-sm {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 0.7rem;
}

.membro-foto-md {
    width: 4.5rem;
    height: 4.5rem;
    font-size: 1.1rem;
}

.membro-foto-lg {
    width: 6rem;
    height: 6rem;
    font-size: 1.35rem;
}

.membro-foto-xl {
    width: 8rem;
    height: 8rem;
    font-size: 1.75rem;
    box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--line);
}

.membro-foto-iniciais {
    background: var(--navy);
}

.membro-foto-campo {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.membro-foto-drop {
    position: relative;
    display: block;
    margin: 0;
    cursor: pointer;
}

.membro-foto-drop .membro-foto {
    width: 7.5rem;
    height: 7.5rem;
    font-size: 1.6rem;
    box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--line);
    transition: box-shadow 0.15s ease;
}

.membro-foto-drop:hover .membro-foto,
.membro-foto-drop:focus-within .membro-foto,
.membro-foto-campo.is-arrasto .membro-foto {
    box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--gold);
}

.membro-foto-camera {
    position: absolute;
    right: 0.15rem;
    bottom: 0.15rem;
    width: 1.85rem;
    height: 1.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--gold);
    color: var(--navy);
    font-size: 0.9rem;
    border: 2px solid var(--paper);
    pointer-events: none;
}

.membro-foto-drop-accao {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: min(18rem, 100%);
    max-width: 28rem;
}

.membro-foto-drop-accao strong {
    font-size: 1rem;
}

.platform-admin {
    min-height: 100vh;
    background: var(--sand);
}

.platform-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.6rem;
}

.badge-estado {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge-estado.is-activa {
    background: rgba(47, 109, 79, 0.12);
    color: var(--ok);
}

.badge-estado.is-experimental {
    background: rgba(217, 148, 47, 0.16);
    color: #8a5a12;
}

.badge-estado.is-suspensa,
.badge-estado.is-em_atraso {
    background: rgba(155, 44, 44, 0.12);
    color: var(--danger);
}

.badge-estado.is-cancelada,
.badge-estado.is-expirada,
.badge-estado.is-indefinido,
.badge-estado.is-rejeitada {
    background: rgba(106, 83, 70, 0.12);
    color: var(--muted);
}

.badge-estado.is-pendente {
    background: rgba(47, 84, 150, 0.12);
    color: #1f3d73;
}

.badge-estado.is-inactivo {
    background: rgba(106, 83, 70, 0.12);
    color: var(--muted);
}

.platform-plan-list,
.platform-feed {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.platform-plan-list li,
.platform-feed li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--line);
}

.platform-plan-list li:last-child,
.platform-feed li:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.platform-feed li {
    align-items: flex-start;
}

.platform-plan-list strong,
.platform-feed .small {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.familia-membros {
    display: grid;
    gap: 0.85rem;
}

.familia-membro-linha {
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--line);
}

.familia-membro-linha:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.membro-pesquisa {
    position: relative;
}

.membro-pesquisa-lista {
    position: absolute;
    z-index: 30;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    max-height: 16rem;
    overflow: auto;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(37, 17, 6, 0.12);
}

.membro-pesquisa-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
}

.membro-pesquisa-item span {
    color: var(--muted);
    font-size: 0.85rem;
}

.membro-pesquisa-item:hover,
.membro-pesquisa-item.is-activo {
    background: var(--sand);
}

.membro-pesquisa-vazio {
    padding: 0.75rem 0.85rem;
    color: var(--muted);
}

.membro-pesquisa-escolhido {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 2.5rem;
    padding: 0.4rem 0.7rem;
    background: var(--sand);
    border: 1px solid var(--line);
    border-radius: 0.375rem;
}

.membro-linhas {
    display: grid;
    gap: 0.85rem;
}

.membro-linha,
.familia-membro-linha {
    align-items: end;
}

.membro-linha-nome {
    font-weight: 600;
    padding-bottom: 0.45rem;
}

@media (max-width: 991.98px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
}
