:root {
    --ink: #12232e;
    --ink-soft: #2c4554;
    --paper: #f6f1e8;
    --paper-2: #fffdf8;
    --line: #e4d9c8;
    --coral: #d4535a;
    --coral-dark: #b63d44;
    --sage: #2f6f4e;
    --gold: #c47b3b;
    --muted: #6b7c86;
    --shadow: 0 18px 50px rgba(18, 35, 46, 0.12);
    --radius: 18px;
    --font: "Source Sans 3", "Segoe UI", sans-serif;
    --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--paper);
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--sage); text-decoration: none; }
a:hover { color: var(--coral); }

h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0 0 .4em; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    border: 0;
    border-radius: 999px;
    padding: .72rem 1.2rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-soft); color: #fff; }
.btn-coral { background: var(--coral); color: #fff; width: 100%; }
.btn-coral:hover { background: var(--coral-dark); color: #fff; width: 100%;}
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: #8b2e2e; color: #fff; }
.btn-small { padding: .4rem .8rem; font-size: .88rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.flash {
    border-radius: 12px;
    padding: .85rem 1rem;
    margin-bottom: 1rem;
}
.flash-ok { background: #e6f4ec; color: var(--sage); }
.flash-erro { background: #fdecee; color: var(--coral-dark); }
.flash-info { background: #eef3f6; color: var(--ink-soft); }

.form-narrow { max-width: 640px; width: 100%; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .92rem; }
.field .hint { color: var(--muted); font-weight: 400; font-size: .85rem; }
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: .75rem .9rem;
    font: inherit;
    font-size: 16px;
    color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid rgba(47, 111, 78, .35);
    border-color: var(--sage);
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 12% 20%, rgba(212, 83, 90, .16), transparent 32%),
        radial-gradient(circle at 88% 80%, rgba(47, 111, 78, .16), transparent 30%),
        var(--paper);
}
.auth-card {
    width: min(440px, calc(100% - 2rem));
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow);
}
.brand {
    font-family: var(--display);
    font-size: 1.7rem;
    margin-bottom: .2rem;
}
.brand span { color: var(--coral); }
.lede { color: var(--muted); margin-bottom: 1.5rem; }

html { -webkit-text-size-adjust: 100%; }
img, video, svg { max-width: 100%; height: auto; }

.menu-toggle {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    z-index: 60;
}
.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform .2s ease, opacity .2s ease;
}
.menu-open .menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
.menu-open .menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.menu-toggle-public {
    position: fixed;
    top: max(.7rem, env(safe-area-inset-top));
    left: max(.7rem, env(safe-area-inset-left));
    background: var(--ink);
    color: #fff;
    box-shadow: var(--shadow);
}
.tema-escuro .menu-toggle-public { background: rgba(18, 35, 46, .85); color: #fff; }

.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18, 35, 46, .45);
    z-index: 40;
}
.nav-overlay[hidden] { display: none; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 55;
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 60px;
    padding: .5rem .9rem .5rem max(.9rem, env(safe-area-inset-left));
    background: var(--ink);
    color: #fff;
    grid-column: 1 / -1;
}
.topbar .brand { color: #fff; font-size: 1.2rem; margin: 0; }
.topbar .menu-toggle { color: #fff; }
.topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    color: #c5d0d6;
    min-width: 0;
}
.topbar-user span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 34vw;
}

.admin-shell {
    display: block;
    min-height: 100vh;
}
.admin-main {
    padding: 1.1rem 1rem 2.5rem;
    min-width: 0;
    transition: margin-left .22s ease;
}
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    background: var(--ink);
    color: #e8eef2;
    padding: 4.4rem .85rem 1.4rem;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform .22s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.menu-open .sidebar { transform: translateX(0); }
.sidebar .brand { color: #fff; font-size: 1.35rem; padding: 0 .6rem 1.2rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: .15rem; }
.sidebar a {
    display: block;
    color: #c5d0d6;
    padding: .75rem .8rem;
    border-radius: 10px;
}
.sidebar a:hover, .sidebar a.active { background: #1c3542; color: #fff; }
.sidebar .who { margin-top: auto; padding: .8rem; color: #9fb0ba; font-size: .88rem; }
.sidebar-public { padding-top: 5rem; }
.sidebar-public .brand { padding-left: .8rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
}
.stat b { display: block; font-family: var(--display); font-size: 1.8rem; }
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table-aprovacao { min-width: 0; }
th, td { padding: .8rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .82rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.badge { display: inline-block; border-radius: 999px; padding: .15rem .6rem; font-size: .78rem; font-weight: 700; }
.badge-ativo, .badge-aprovado { background: #e6f4ec; color: var(--sage); }
.badge-pendente { background: #fff4e5; color: var(--gold); }
.badge-encerrado, .badge-inativo, .badge-rejeitado { background: #fdecee; color: var(--coral-dark); }
.badge-admin { background: var(--ink); color: #fff; }
.badge-operador { background: #eef3f6; color: var(--ink-soft); }
.badge-palavra, .badge-frase { background: #eef3f6; color: var(--ink-soft); }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.filters { display: flex; gap: .7rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: min(100%, 180px); flex: 1 1 180px; }

.qr-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; text-align: center; }
.qr-box img,
.qr-box svg { width: min(220px, 70vw); height: auto; aspect-ratio: 1; display: block; margin: 0 auto; }
.copy-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.copy-row input { flex: 1 1 180px; min-width: 0; }

.aprovacao-cell { padding: 0; }
.aprovacao-row {
    display: grid;
    grid-template-columns: minmax(160px, 1.4fr) 56px 1fr 1fr 1fr 130px auto;
    gap: .6rem;
    align-items: center;
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--line);
}
.aprovacao-row.has-evento {
    grid-template-columns: minmax(140px, 1.2fr) 56px 1fr 1fr 1fr 1fr 120px auto;
}
.aprovacao-row input[name="texto"] { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; font: inherit; }

.public-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: .8rem;
    flex-wrap: wrap;
    padding: 1rem 1.2rem .6rem;
    flex-shrink: 0;
}
.public-top-centro { text-align: center; }
.public-top-centro h1 {
    font-size: clamp(1.8rem, 4.2vw, 3.2rem);
    margin: 0;
    line-height: 1.15;
    font-weight: 700;
}
.nuvem-shell {
    min-height: 100vh;
    height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    grid-template-rows: 1fr;
    align-items: stretch;
}
.cloud-main {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
}
.cloud-stage {
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
}
.nuvem-html {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    align-content: center;
    gap: .35rem .8rem;
    width: 100%;
    flex: 1;
    min-height: 0;
    padding: .5rem 1rem;
}
.nuvem-html span {
    line-height: 1.05;
    font-weight: 800;
    max-width: 100%;
    text-align: center;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .18);
}
.tema-escuro .nuvem-html span {
    text-shadow: 0 2px 8px rgba(0, 0, 0, .55);
}
.cloud-footer {
    flex-shrink: 0;
    padding: .8rem 1.2rem 1.1rem;
}
.people {
    min-width: 0;
    margin-top: .85rem;
    padding-top: .85rem;
    border-top: 1px solid var(--line);
    flex: 1 1 auto;
    min-height: 0;
}
.cloud-side {
    min-width: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    border-left: 1px solid var(--line);
    padding: .5rem 1rem 1rem;
    overflow-y: auto;
}
.cloud-share {
    flex: 0 0 auto;
    text-align: center;
    margin: 0;
    padding: 0;
    line-height: 0;
}
body.pagina-nuvem .cloud-share img,
body.pagina-nuvem .cloud-share svg {
    width: 230px;
    height: 230px;
    max-width: 230px;
    max-height: 230px;
    object-fit: contain;
    background: #fff;
    padding: 8px;
    border-radius: 14px;
    display: block;
    margin: 0 auto;
}
.cloud-link {
    display: block;
    width: 100%;
    margin: 0;
    padding: .7rem 1rem;
    font-size: clamp(1.25rem, 2.6vw, 2.1rem);
    font-weight: 800;
    letter-spacing: .01em;
    line-height: 1.3;
    word-break: break-all;
    overflow-wrap: anywhere;
    text-align: center;
    background: #fff;
    color: #12232e;
    border-radius: 14px;
}
.people h2 { font-size: 1.25rem; }
.people ul { list-style: none; margin: 0; padding: 0; }
.people li { padding: .65rem 0; border-bottom: 1px solid var(--line); word-break: break-word; font-size: 1.12rem; }
.people .who-name { font-weight: 700; }
.people .arrow { color: var(--muted); margin: 0 .35rem; }
.people .who-word { font-weight: 600; }

.send-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem 1rem;
    background: color-mix(in srgb, var(--evento-fundo, var(--paper)) 82%, #000);
}
.pagina-envio {
    background: var(--evento-fundo, var(--paper));
    min-height: 100vh;
    color: var(--ink);
}
.send-identidade {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 1.1rem;
}
.send-identidade h1 {
    margin: 0;
    font-size: clamp(1.5rem, 4.2vw, 2.2rem);
    line-height: 1.15;
}
.send-identidade .evento-logo {
    height: 96px;
    max-width: min(280px, 80vw);
}
.send-card {
    width: min(520px, 100%);
    background: var(--evento-fundo, var(--paper-2));
    border: 0;
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow:
        0 22px 60px rgba(18, 35, 46, .32),
        0 0 0 1px rgba(18, 35, 46, .12);
}
.suggest { position: relative; }
.suggest-list {
    position: absolute;
    left: 0; right: 0; top: 100%;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-top: .3rem;
    z-index: 5;
    overflow: hidden;
}
.suggest-list button {
    display: block; width: 100%; text-align: left;
    background: #fff; border: 0; padding: .7rem .9rem; font: inherit; cursor: pointer;
}
.suggest-list button:hover { background: var(--paper); }
.ok-msg { background: #e6f4ec; color: var(--sage); padding: .8rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 600; }

.landing {
    min-height: 100vh;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 5rem 1.2rem 2rem;
}
.landing h1 { font-size: clamp(2rem, 7vw, 4.2rem); }
.landing p { color: var(--muted); max-width: 36rem; margin: 0 auto 1.4rem; }

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

.color-row { display: flex; gap: .6rem; align-items: center; }
.color-row input[type="color"] {
    width: 56px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.color-row input[type="text"] { max-width: 120px; }
.logo-preview {
    margin: .4rem 0 .7rem;
    padding: .7rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    display: inline-block;
}
.logo-preview img { max-height: 72px; max-width: 220px; object-fit: contain; display: block; }
.logo-preview-box {
    display: flex;
    align-items: flex-end;
    gap: .8rem;
    flex-wrap: wrap;
    margin: .7rem 0 .4rem;
    padding: .8rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.logo-preview-box[hidden] { display: none; }
.logo-preview-box img {
    max-height: 96px;
    max-width: min(280px, 100%);
    object-fit: contain;
    display: block;
    background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 12px 12px;
    border-radius: 8px;
}
.tema-preview {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem .9rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--evento-fundo, #fff);
}
.tema-preview img { max-height: 48px; max-width: 140px; object-fit: contain; }
.tema-swatch {
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--evento-fundo, #fff);
    border: 1px solid rgba(0,0,0,.15);
}

.pagina-nuvem {
    background: var(--evento-fundo, var(--paper));
    min-height: 100vh;
    color: var(--ink);
}
.evento-identidade { display: flex; flex-direction: column; align-items: center; gap: .75rem; }
.evento-logo { height: 200px; width: auto; max-width: min(420px, 86vw); object-fit: contain; display: block; }
.btn-ghost-light { border-color: rgba(255,255,255,.35); color: #fff; }
.btn-ghost-light:hover { background: rgba(255,255,255,.12); color: #fff; }

.tema-escuro { color: #f6f1ea; }
.tema-escuro .people {
    border-color: rgba(255,255,255,.12);
}
.tema-escuro .cloud-side {
    border-color: rgba(255,255,255,.12);
    background: rgba(0,0,0,.16);
}
.tema-escuro .cloud-link { background: #fff; color: #12232e; }
.tema-escuro .people li { border-color: rgba(255,255,255,.12); }
.tema-escuro .people .arrow,
.tema-escuro .empty { color: rgba(246,241,234,.7); }
.tema-escuro.send-wrap,
.pagina-envio.tema-escuro .send-wrap {
    background: color-mix(in srgb, var(--evento-fundo, #111) 72%, #fff);
}
.pagina-envio.tema-escuro .send-card {
    color: #f6f1ea;
    box-shadow:
        0 22px 60px rgba(0, 0, 0, .55),
        0 0 0 1px rgba(255, 255, 255, .22),
        0 8px 32px rgba(255, 255, 255, .08);
}
.pagina-envio.tema-escuro .send-card h1,
.pagina-envio.tema-escuro .send-card p,
.pagina-envio.tema-escuro .send-card label {
    color: #f6f1ea;
}
.pagina-envio.tema-escuro .send-card .hint {
    color: rgba(246, 241, 234, .72);
}

@media (max-width: 1023px) {
    .hide-sm { display: none !important; }
    .topbar-user { display: none; }
    .nuvem-shell {
        height: auto;
        min-height: 100vh;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    .cloud-stage { min-height: 48vh; }
    .cloud-side {
        width: 100%;
        border-left: 0;
        border-top: 1px solid var(--line);
        max-height: none;
    }
    .evento-logo { height: 84px; max-width: 240px; }
    .evento-identidade { gap: .55rem; }
    .auth-card { padding: 1.4rem; border-radius: 18px; }
    .page-head .btn, .page-head a.btn { width: 100%; }
    .filters { flex-direction: column; }
    .filters .field { min-width: 0; }
    .table-aprovacao thead { display: none; }
    .aprovacao-row,
    .aprovacao-row.has-evento {
        grid-template-columns: 1fr 1fr;
        padding: 1rem;
    }
    .aprovacao-row input[name="texto"] { grid-column: 1 / -1; }
    .aprovacao-row .aprovacao-meta { grid-column: 1 / -1; font-size: .88rem; color: var(--muted); }
    .aprovacao-row .actions { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
    h1 { font-size: 1.45rem; }
    .btn { min-height: 44px; }
    .send-card { padding: 1.2rem; border-radius: 18px; }
    .logo-preview-box { flex-direction: column; align-items: flex-start; }
    .copy-row .btn { width: 100%; }
}

@media (min-width: 1024px) {
    .admin-body .nav-overlay { display: none !important; }
    .admin-body .sidebar {
        top: 60px;
        height: calc(100vh - 60px);
        width: 250px;
        padding-top: 1.1rem;
    }
    .admin-body.menu-open .admin-main { margin-left: 250px; }
    .admin-main { padding: 1.6rem 1.8rem 3rem; }
    .admin-body .topbar-user span:first-child { max-width: 220px; }
    .sidebar-public { top: 0; height: 100vh; padding-top: 5rem; }
}
