:root {
    --bg: #f3f5f7;
    --paper: #ffffff;
    --ink: #0f172a;
    --muted: #475569;
    --line: #d8dee6;

    /* Azul institucional */
    --brand: #2f3f58;

    --radius: 10px;
    --shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: Calibri, "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.wrap {
    width: min(1100px, calc(100% - 28px));
    margin: 0 auto;
}

/* ================= Topbar ================= */

.topbar {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    /* CORREÇÃO: Define a topbar acima de tudo */
    position: relative;
    z-index: 100;
}

.topbar--blue {
    background: var(--brand);
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.topbar__inner {
    display: flex;
    align-items: center;
    justify-content: center;
    /* centro real */
    gap: 16px;
    padding: 18px 0;
    position: relative;
}

/* Ações sempre no canto direito (corrige o "Sair" na esquerda) */
.topbar__actions {
    position: absolute;
    right: 0;
    /* CORREÇÃO: Removemos o transform que bugava o dropdown */
    /* top: 50%; transform: translateY(-50%); <- REMOVIDO */
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
}

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

.brand--textonly {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.brand__logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
}

.brand__titles {
    line-height: 1.1;
}

.brand__name {
    font-weight: 700;
    letter-spacing: 0.08em;
    font-size: 14px;
    color: var(--brand);
}

/* Nome grande e branco no topo azul */
.brand__name--white {
    color: #ffffff;
    font-weight: 800;
    letter-spacing: 0.08em;
    font-size: 36px;
    line-height: 1;

    /* Fonte mais sóbria (menos arredondada) */
    font-family: "Calibri", Arial, sans-serif;
}

.brand__name--link {
    text-decoration: none;
}

.brand__name--link:hover {
    text-decoration: none;
}

.brand__subtitle {
    margin-top: 4px;
    font-size: 14px;
    color: var(--muted);
}

.topbar--blue .btn--ghost {
    background: transparent;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.45);
}

.topbar--blue .btn--ghost:hover {
    background: rgba(255, 255, 255, 0.10);
    text-decoration: none;
}

@media (max-width: 520px) {
    .brand__name--white {
        font-size: 28px;
        letter-spacing: 0.07em;
    }

    .topbar__inner {
        padding: 16px 0;
    }

    /* Mantém o botão acessível sem atrapalhar o centro */
    .topbar__actions {
        right: 0;
    }
}

/* ================= Menu ================= */

.menubar {
    background: #f6f7f9;
    border-bottom: 1px solid var(--line);
    /* CORREÇÃO: Define o menu abaixo da topbar */
    position: relative;
    z-index: 90;
}

.menubar__inner {
    display: flex;
    align-items: center;
    justify-content: center;
    /* centraliza o menu na web */
    gap: 10px;
    padding: 10px 0;
    min-height: 44px;
}

.menubar__link {
    font-size: 14px;
    font-weight: 600;
    color: var(--brand);
    padding: 6px 6px;
    border-radius: 6px;
}

.menubar__link:hover {
    background: rgba(47, 63, 88, 0.08);
    text-decoration: none;
}

.menubar__sep {
    color: #9aa3ad;
    user-select: none;
}

/* Mobile: por enquanto só quebra linha.
   Quando você quiser o hamburger DE VERDADE, a gente adiciona um botão no HTML + um mini JS. */
@media (max-width: 520px) {
    .menubar__inner {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* ================= Main ================= */

.main {
    padding: 18px 0 26px;
}

/* ================= Alerts ================= */

.alert {
    border: 1px solid var(--line);
    background: var(--paper);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin: 0 0 14px;
    box-shadow: var(--shadow);
    font-size: 14px;
}

.alert--error {
    border-color: #f1c6c6;
    background: #fff5f5;
}

.alert--ok {
    border-color: #c8e6c9;
    background: #f3fff4;
}

.alert--warn {
    border-color: #faebcc;
    background: #fcf8e3;
    color: #6b4b12;
}

.alert--neutral {
    border-color: #e5e7eb;
    background: #f7f7f7;
    color: #374151;
}

/* ================= Layout ================= */

.grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 16px;
    align-items: start;
}

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

/* ================= Cards ================= */

.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card__head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: #fbfcfd;
}

.card__head--split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card__title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--ink);
}

/* ================= Table ================= */

.table {
    display: grid;
    width: 100%;
}

.table__row {
    display: grid;
    grid-template-columns: 1.2fr 0.6fr 0.7fr;
    border-bottom: 1px solid var(--line);
}

.table__row:last-child {
    border-bottom: none;
}

.table__row--head {
    background: #e7eff8;
    border-bottom: 1px solid #cbd9ea;
}

.table__cell {
    padding: 12px 14px;
    font-size: 14px;
    color: var(--ink);
}

.table__row--head .table__cell {
    font-weight: 700;
    color: var(--brand);
}

.table__cell--center {
    text-align: center;
    color: var(--muted);
}

.table__cell--right {
    text-align: right;
}

.money {
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    /* Impede quebra de linha no valor */
}

/* NOVO: Taxa mensal contratada */
.rate {
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* ================= Mobile: Tabela responsiva ================= */
@media (max-width: 520px) {
    .table__row {
        grid-template-columns: 1fr auto;
        /* Descrição + Valor */
        grid-template-rows: auto auto;
        /* 2 linhas: principal + data */
    }

    /* Cabeçalho no mobile: apenas 2 colunas visíveis */
    .table__row--head {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto;
    }

    /* Esconde o cabeçalho da coluna "Data" no mobile */
    .table__row--head .table__cell:nth-child(2) {
        display: none;
    }

    /* Título "Valor de referência" alinhado à direita */
    .table__row--head .table__cell:nth-child(3) {
        text-align: right;
    }

    /* Célula da descrição */
    .table__row:not(.table__row--head) .table__cell:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
    }

    /* Célula do valor - fica à direita */
    .table__row:not(.table__row--head) .table__cell:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
        text-align: right;
    }

    /* Célula da data - vai para baixo, ocupando toda a largura */
    .table__row:not(.table__row--head) .table__cell:nth-child(2) {
        grid-column: 1 / -1;
        grid-row: 2;
        text-align: left;
        padding-top: 0;
        font-size: 12px;
        color: var(--muted);
    }

    /* Esconde linha de data se estiver vazia */
    .table__row:not(.table__row--head) .table__cell:nth-child(2):empty {
        display: none;
    }
}

/* ================= Forms ================= */

.form {
    padding: 14px 16px;
}

.form__row {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

.label {
    font-size: 13px;
    color: var(--muted);
}

.input {
    width: 100%;
    padding: 10px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    background: #fff;
}

.input:focus {
    border-color: #b9c7d9;
    box-shadow: 0 0 0 3px rgba(47, 63, 88, 0.12);
}

.form__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ================= Buttons ================= */

.btn {
    border: 1px solid var(--brand);
    background: var(--brand);
    color: #fff;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.btn:hover {
    filter: brightness(0.98);
}

.btn--ghost {
    background: transparent;
    color: var(--brand);
    border-color: #b9c7d9;
}

.btn--ghost:hover {
    background: #f1f6fb;
    text-decoration: none;
}

/* ================= Key/Value list ================= */

.kv {
    padding: 12px 16px 14px;
    margin: 0;
}

.kv__row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed #e6ebf2;
}

.kv__row:last-child {
    border-bottom: none;
}

.kv dt {
    margin: 0;
    font-size: 12.5px;
    color: var(--muted);
}

.kv dd {
    margin: 0;
    font-size: 14px;
    color: var(--ink);
    word-break: break-word;
}

.divider {
    height: 1px;
    background: var(--line);
    margin: 0 16px;
}

.note {
    padding: 0 16px 14px;
    font-size: 12.5px;
    color: var(--muted);
}

/* ================= Login block ================= */

.auth {
    display: grid;
    place-items: center;
    padding: 22px 0;
}

.auth__card {
    width: min(520px, 100%);
}

.auth__links {
    padding: 0 16px 16px;
    font-size: 13px;
    color: var(--muted);
}

/* ================= Footer ================= */

.footer {
    margin-top: 14px;
    padding: 10px 2px 0;
    color: var(--muted);
}

.footer__line {
    height: 1px;
    background: var(--line);
    margin-bottom: 10px;
}

.footer__text,
.footer__support {
    margin: 6px 0;
    font-size: 11.5px;
}

.footer__text {
    text-align: justify;
}

.footer__support {
    text-align: center;
}