:root {
    --gold: #C9A961;
    --gold-light: #E0C57A;
    --gold-dark: #8E7536;
    --bg: #0E0E0E;
    --bg-soft: #1A1816;
    --bg-card: #FFFFFF;
    --text: #11181c;
    --muted: #687076;
    --line: #E5E7EB;
    --wa: #25D366;
}
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ===== Trava de overflow horizontal (causa raiz da rolagem lateral no iPhone SE) ===== */
html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;            /* sem rolagem lateral nunca */
    overscroll-behavior-x: none;   /* desabilita swipe horizontal nativo */
    -webkit-text-size-adjust: 100%;
    touch-action: pan-y;           /* só permite gestos verticais */
}
html { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background:
        radial-gradient(circle at 20% 0%, rgba(201,169,97,.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 100%, rgba(201,169,97,.08) 0%, transparent 50%),
        #0E0E0E;
    min-height: 100vh;
    min-height: 100dvh;            /* dynamic viewport — respeita barra do Safari */
    display: flex;
    flex-direction: column;
    color: #F5EFE6;
    /* padding pra notch/safe-area do iPhone — só com env(), nada de fallback fixo
       que poderia somar largura e causar overflow */
    padding-top:    env(safe-area-inset-top, 0px);
    padding-right:  env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left:   env(safe-area-inset-left, 0px);
}
img, svg { max-width: 100%; display: block; }

/* ===== Header com logo ===== */
.app-header {
    text-align: center;
    padding: 20px 16px 14px;       /* compacto pra caber em telas pequenas */
    flex-shrink: 0;
}
.app-header img {
    width: clamp(80px, 22vw, 110px);  /* escala com a tela, nunca quebra */
    height: auto;
    filter: drop-shadow(0 4px 20px rgba(201,169,97,.45));
    margin: 0 auto;
    transition: transform .3s;
}
.app-header img:active { transform: scale(.95); }
.app-header h1 {
    font-size: 15px;
    color: var(--gold);
    margin-top: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 600;
}
.app-header p {
    font-size: 11px;
    color: #A89B86;
    margin-top: 2px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ===== Card central com o form ===== */
.app-main {
    flex: 1 1 auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12px 14px;
    width: 100%;
}
.app-card {
    background: #FFFFFF;
    color: var(--text);
    width: 100%;
    max-width: 420px;
    border-radius: 20px;
    padding: 28px 22px 24px;
    box-shadow: 0 24px 60px rgba(0,0,0,.45), 0 0 0 1px rgba(201,169,97,.15);
}
.app-card h2 {
    font-size: 20px;
    color: var(--text);
    margin-bottom: 4px;
    font-weight: 700;
}
.app-card p.sub {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 18px;
}

/* Tab switcher Entrar / Registrar */
.auth-tabs {
    display: flex;
    background: #F3F4F6;
    border-radius: 999px;
    padding: 4px;
    margin-bottom: 18px;
    width: 100%;
}
.auth-tabs a {
    flex: 1 1 0;
    min-width: 0;                  /* deixa flex shrink corretamente */
    text-align: center;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    transition: all .2s;
    white-space: nowrap;
}
.auth-tabs a.active {
    background: var(--gold);
    color: var(--bg);
    box-shadow: 0 4px 12px rgba(201,169,97,.35);
}

/* Form fields */
.field { margin-bottom: 12px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.field input, .field select {
    width: 100%;
    padding: 13px 14px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    font-size: 16px;              /* >= 16px evita zoom automático do iOS */
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}
.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201,169,97,.18);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--gold);
    color: var(--bg);
    border: 0;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s, background .15s;
    box-shadow: 0 6px 16px rgba(201,169,97,.35);
    -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover { background: var(--gold-light); }
.btn-primary:active { transform: scale(.98); }

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 14px;
    word-wrap: break-word;
}
.alert-error   { background: #FEF2F2; color: #991B1B; border-left: 3px solid #DC2626; }
.alert-success { background: #F0FDF4; color: #166534; border-left: 3px solid #16A34A; }

.secondary-link {
    display: block;
    text-align: center;
    margin-top: 14px;
    font-size: 13px;
    color: var(--muted);
}
.secondary-link a { color: var(--gold-dark); font-weight: 600; text-decoration: none; }

/* ===== Footer: site + WhatsApp ===== */
.app-footer {
    padding: 12px 16px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    flex-shrink: 0;
}
/* Botão "Ir ao site" — outlined gold, acima do WhatsApp */
.site-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--gold);
    border: 1.5px solid var(--gold);
    text-decoration: none;
    padding: 11px 22px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    transition: all .15s;
    -webkit-tap-highlight-color: transparent;
    max-width: 100%;
}
.site-btn:hover { background: var(--gold); color: var(--bg); }
.site-btn:active { transform: scale(.97); }
.site-btn svg { width: 16px; height: 16px; fill: currentColor; }

.wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--wa);
    color: #fff;
    text-decoration: none;
    padding: 13px 22px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(37,211,102,.4);
    transition: transform .15s;
    -webkit-tap-highlight-color: transparent;
    max-width: 100%;
}
.wa-btn:hover { transform: translateY(-2px); }
.wa-btn:active { transform: scale(.97); }
.wa-btn svg { width: 20px; height: 20px; fill: #fff; }

.app-footer .helper {
    font-size: 11px;
    color: #A89B86;
    text-align: center;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Back-link no topo (modo navegador) — esconde em standalone via JS */
.back-link {
    position: fixed;
    top: max(env(safe-area-inset-top, 0px), 12px);
    left: 12px;
    color: var(--gold);
    text-decoration: none;
    font-size: 12px;
    background: rgba(255,255,255,.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 7px 12px;
    border-radius: 999px;
    z-index: 5;
    max-width: calc(100% - 24px);  /* nunca passa da tela */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* iPhone SE (375px) e menores */
@media (max-width: 380px) {
    .app-card { padding: 22px 18px 20px; border-radius: 18px; }
    .app-header { padding-top: 14px; padding-bottom: 10px; }
    .app-header h1 { font-size: 14px; }
    .auth-tabs a { padding: 9px 6px; font-size: 12px; }
    .site-btn, .wa-btn { padding: 11px 18px; font-size: 13px; }
}
