/* =============================================================================
   CONEXÃO ATIVA — Área do cliente (portal de pagamento)
   Preto + dourado da marca sobre fundo claro: é o cliente quem usa, no
   celular, vindo de um link do WhatsApp. Tudo sai dos tokens abaixo.
   ============================================================================= */

:root {
    --brand: #FDB813;
    --brand-dark: #E09600;
    --brand-soft: #FFF4D6;
    --brand-line: rgba(253, 184, 19, 0.45);

    --ink: #0B0B0D;
    --ink-2: #15161A;
    --ink-3: #1F2126;

    --bg: #F4F5F7;
    --card: #FFFFFF;
    --line: #E6E8EC;
    --line-strong: #D5D8DE;

    --text: #15161A;
    --text-soft: #4B5059;
    --muted: #7A808A;

    --ok: #1E9E5A;
    --ok-soft: #E6F6EC;
    --warn: #B76E00;
    --warn-soft: #FFF4D6;
    --bad: #D4383C;
    --bad-soft: #FCE9EA;
    --info: #2C6BD1;
    --info-soft: #E8F0FD;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 20px rgba(16, 24, 40, 0.06);
    --sidebar: 272px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
button, input { font: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---- Marca ------------------------------------------------------------- */
.marca { display: inline-flex; align-items: center; text-decoration: none; line-height: 0; }
.marca img { height: 56px; width: auto; display: block; }

/* ---- Botões ------------------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
    transition: transform .06s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
    -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--brand); color: var(--ink); box-shadow: 0 4px 14px rgba(253, 184, 19, 0.35); }
.btn-primary:hover { background: #FFC431; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-3); }
.btn-outline { background: var(--card); color: var(--text); border-color: var(--line-strong); }
.btn-outline:hover { border-color: var(--ink); }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: rgba(0, 0, 0, 0.05); }
.btn-block { width: 100%; }
.btn-lg { padding: 15px 22px; font-size: 16px; border-radius: 12px; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---- Campos ------------------------------------------------------------ */
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.campo label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.campo input {
    padding: 13px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: #fff; font-size: 16px; color: var(--text); outline: none; width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.campo input:focus { border-color: var(--brand-dark); box-shadow: 0 0 0 3px var(--brand-line); }
.campo .dica { font-size: 12px; color: var(--muted); }

/* ---- Avisos e selos ---------------------------------------------------- */
.aviso { padding: 14px 16px; border-radius: var(--radius-sm); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.aviso svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.aviso.bad { background: var(--bad-soft); color: #8E1F22; }
.aviso.ok { background: var(--ok-soft); color: #0F5F36; }
.aviso.warn { background: var(--warn-soft); color: #6B4200; }
.aviso.info { background: var(--info-soft); color: #1B437F; }

.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.neutro { background: #EEF0F3; color: var(--text-soft); }

/* ---- Login ------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-marca {
    background: radial-gradient(1200px 600px at -10% -10%, rgba(253, 184, 19, 0.28), transparent 55%),
                radial-gradient(800px 500px at 110% 110%, rgba(253, 184, 19, 0.18), transparent 60%),
                var(--ink);
    color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-marca h1 { font-size: 36px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 14px; max-width: 460px; }
.login-marca h1 em { font-style: normal; color: var(--brand); }
.login-marca p { color: rgba(255, 255, 255, 0.72); font-size: 16px; max-width: 420px; margin: 0; }
.login-passos { display: grid; gap: 12px; margin-top: 28px; max-width: 420px; }
.passo { display: flex; gap: 12px; align-items: center; color: rgba(255, 255, 255, 0.85); font-size: 14px; }
.passo b { width: 28px; height: 28px; border-radius: 8px; background: rgba(253, 184, 19, 0.16); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.login-rodape { color: rgba(255, 255, 255, 0.45); font-size: 12px; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 6px; }
.login-card .sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.login-card .marca { display: none; margin-bottom: 20px; }
.login-card .marca img { height: 76px; }
.login-marca .marca img { height: 90px; }

/* ---- Estrutura logada -------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
    background: var(--ink); color: #fff; padding: 26px 18px; display: flex; flex-direction: column; gap: 28px;
    position: sticky; top: 0; height: 100vh;
}
.sidebar .marca { padding: 0 8px; }
.sidebar .marca img { height: 84px; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
    color: rgba(255, 255, 255, 0.72); font-weight: 600; background: transparent; border: 0; cursor: pointer; text-align: left; width: 100%;
    transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 20px; height: 20px; flex: none; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.ativo { background: rgba(253, 184, 19, 0.16); color: var(--brand); }
.sidebar .espaco { flex: 1; }
.sidebar .rodape { font-size: 12px; color: rgba(255, 255, 255, 0.4); padding: 0 8px; }

.main { min-width: 0; }
.topbar {
    background: var(--card); border-bottom: 1px solid var(--line); padding: 14px 28px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 5;
}
.topbar .marca { display: none; }
.contrato-linha { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; flex: 1; }
.contrato-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.contrato-chip b { font-size: 13px; letter-spacing: 0.04em; white-space: nowrap; }
.contrato-chip span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { padding: 28px; max-width: 980px; }
.saudacao { margin: 4px 0 22px; }
.saudacao small { display: block; color: var(--muted); font-size: 15px; }
.saudacao h1 { margin: 2px 0 0; font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.titulo-secao { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 26px 0 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.grade { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.kv { display: grid; gap: 12px; }
.kv div { display: flex; flex-direction: column; gap: 2px; }
.kv dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }

/* ---- Chave "Todos os contratos" ---------------------------------------- */
.chave {
    display: inline-flex; align-items: center; gap: 10px; margin: 0 0 14px; padding: 0; border: 0; background: transparent;
    font-weight: 600; font-size: 14px; color: var(--text-soft); cursor: pointer;
}
.chave-botao { width: 42px; height: 24px; border-radius: 999px; background: #D5D8DE; position: relative; transition: background .15s ease; flex: none; }
.chave-botao::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: left .15s ease; }
.chave.ligada { color: var(--text); }
.chave.ligada .chave-botao { background: var(--brand); }
.chave.ligada .chave-botao::after { left: 21px; }

/* ---- Faturas ----------------------------------------------------------- */
.faturas { display: grid; gap: 12px; }
.fatura { padding: 18px 20px; display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.fatura.vencida { border-color: rgba(212, 56, 60, 0.35); }
.fatura > div { min-width: 0; }
.fatura-cabeca { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; min-width: 0; }
/* A etiqueta do contrato traz o endereço: pode quebrar linha, não estourar o cartão. */
.fatura-cabeca .badge.neutro { white-space: normal; text-align: left; line-height: 1.3; }
.fatura-cabeca h3 { margin: 0; font-size: 16px; font-weight: 700; }
.fatura-meta { color: var(--muted); font-size: 13px; }
.fatura-valor { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; text-align: right; }
.fatura-valor small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.fatura-acoes { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; }
.vazio { padding: 36px 20px; text-align: center; color: var(--muted); }
.vazio .icone { width: 52px; height: 52px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.vazio .icone svg { width: 26px; height: 26px; }
.vazio.ok .icone { background: var(--ok-soft); color: var(--ok); }
.vazio h3 { margin: 0 0 4px; color: var(--text); font-size: 17px; }

.abas { display: inline-flex; background: #EEF0F3; padding: 4px; border-radius: 12px; gap: 4px; margin-bottom: 16px; }
.aba { padding: 8px 16px; border-radius: 9px; border: 0; background: transparent; font-weight: 600; color: var(--text-soft); cursor: pointer; }
.aba.ativa { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }

/* ---- Pix (folha/modal) ------------------------------------------------- */
.pix-fundo { position: fixed; inset: 0; background: rgba(11, 11, 13, 0.55); display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 0; animation: surgir .15s ease; }
.pix {
    background: var(--card); width: 100%; max-width: 480px; border-radius: 22px 22px 0 0; padding: 18px 20px 28px;
    max-height: 92vh; overflow: auto; animation: subir .2s ease;
}
.pix-topo { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pix-topo h2 { margin: 0; font-size: 18px; font-weight: 800; }
.fechar { border: 0; background: #EEF0F3; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.fechar svg { width: 18px; height: 18px; }
.pix-valor { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 6px 0 14px; }
.pix-valor b { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.pix-valor span { color: var(--muted); font-size: 13px; }
.qr { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 0 auto 14px; width: 232px; height: 232px; display: flex; align-items: center; justify-content: center; }
.qr svg { width: 100%; height: 100%; display: block; }
.qr-ausente { font-size: 12px; color: var(--muted); text-align: center; }
.codigo {
    margin: 12px 0 0; padding: 12px 14px; background: #F7F8FA; border: 1px dashed var(--line-strong); border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--text-soft);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; user-select: all; -webkit-user-select: all;
}
.como { margin: 16px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 13.5px; color: var(--text-soft); }
.como li { display: flex; gap: 10px; align-items: flex-start; }
.como b { width: 22px; height: 22px; border-radius: 7px; background: var(--brand-soft); color: var(--brand-dark); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.pix-secundario { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin-top: 14px; }
.copiado { background: var(--ok) !important; color: #fff !important; box-shadow: none !important; }

/* ---- Página do link (/pagar/t/...) ------------------------------------- */
.link-pagina { min-height: 100vh; display: flex; flex-direction: column; }
.link-topo { background: var(--ink); padding: 14px 20px; display: flex; justify-content: center; }
.link-topo .marca img { height: 58px; }
.link-corpo { flex: 1; display: flex; justify-content: center; padding: 24px 16px 40px; }
.link-card { width: 100%; max-width: 480px; }
.link-card .pix { border-radius: var(--radius); max-height: none; animation: none; padding: 22px 20px 24px; }
.link-rodape { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.link-rodape a { color: var(--text); font-weight: 600; }

/* ---- Toast e esqueleto ------------------------------------------------- */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
    padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 100; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    max-width: calc(100% - 32px); text-align: center;
}
.skel { background: linear-gradient(90deg, #EEF0F3 25%, #F7F8FA 50%, #EEF0F3 75%); background-size: 200% 100%; animation: brilho 1.2s infinite; border-radius: 8px; height: 14px; }
.skel.alto { height: 22px; }
.skel-card { padding: 20px; display: grid; gap: 12px; }

@keyframes brilho { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes subir { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes surgir { from { opacity: 0; } to { opacity: 1; } }

/* ---- Celular ----------------------------------------------------------- */
.tabbar { display: none; }

@media (min-width: 861px) {
    .pix-fundo { align-items: center; padding: 20px; }
    .pix { border-radius: 22px; }
}

@media (max-width: 860px) {
    /* Celular: faixa preta só com a logo centralizada e o formulário num
       cartão branco que sobe um pouco sobre a faixa. */
    .login { display: block; background: var(--bg); min-height: 100vh; }
    .login-marca { display: flex; justify-content: center; align-items: center; padding: 36px 20px 64px; min-height: 0; }
    .login-marca > div:not(:first-child) { display: none; }
    .login-marca .marca img { height: 68px; }
    .login-form { padding: 0 16px 40px; margin-top: -34px; align-items: flex-start; }
    .login-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px 18px 20px; box-shadow: var(--shadow); }
    .login-card .marca { display: none; }
    .login-card h2, .login-card .sub { text-align: center; }
    .login-card h2 { font-size: 22px; }

    .shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    /* No celular a marca ganha a faixa preta dela (como a lateral do
       desktop); a linha do contrato fica na faixa branca logo abaixo. */
    .topbar { padding: 0; flex-direction: column; align-items: stretch; gap: 0; }
    .topbar .marca { display: flex; background: var(--ink); padding: 12px 16px; }
    .topbar .marca img { height: 52px; }
    .topbar .contrato-linha { padding: 10px 16px; }
    .content { padding: 18px 16px 96px; }
    .saudacao h1 { font-size: 24px; }
    .fatura { padding: 16px; }
    .fatura-valor { font-size: 20px; }

    .tabbar {
        display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
        background: var(--ink); padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    }
    .tabbar .nav-item { flex-direction: column; gap: 4px; font-size: 11px; padding: 8px 4px; justify-content: center; }
    .tabbar .nav-item svg { width: 22px; height: 22px; }
}
