:root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2a2f3a;
    --text: #e7eaf1;
    --muted: #9aa3b2;
    --accent: #6c8cff;
    --accent-2: #8a6cff;
    --danger: #ff6b6b;
    --ok: #35c48a;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: .4rem; padding: .6rem 1rem; border-radius: 10px;
    border: 1px solid transparent; cursor: pointer; font-size: .95rem;
    font-weight: 600; transition: .15s;
}
.btn-primary {
    width: 100%; background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; border: none; margin-top: .5rem;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); text-decoration: none; }

/* ---------- Autenticação ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem;
    background: radial-gradient(1200px 600px at 50% -10%, #1b2030, var(--bg)); }
.auth-card {
    width: 100%; max-width: 380px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 2rem; box-shadow: var(--shadow);
}
.auth-card h1 { margin: .25rem 0 1.25rem; font-size: 1.4rem; }
.auth-card label { display: block; margin-bottom: .9rem; font-size: .85rem; color: var(--muted); }
.auth-card input {
    width: 100%; margin-top: .35rem; padding: .65rem .75rem;
    background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    color: var(--text); font-size: 1rem;
}
.auth-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.auth-switch { margin: 1.1rem 0 0; text-align: center; color: var(--muted); font-size: .9rem; }

.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; letter-spacing: .2px; }
.brand-mark { font-size: 1.3rem; }

.alert {
    background: rgba(255,107,107,.12); border: 1px solid rgba(255,107,107,.4);
    color: #ffb4b4; padding: .7rem .9rem; border-radius: 10px; margin-bottom: 1rem; font-size: .9rem;
}
.alert-ok {
    background: rgba(53,196,138,.12); border-color: rgba(53,196,138,.4); color: #9ff0cd;
}

/* ---------- Topbar ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: .9rem 1.5rem; background: var(--surface);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.user-email { color: var(--muted); font-size: .9rem; }

.container { max-width: 1000px; margin: 0 auto; padding: 1.5rem; }

/* ---------- Dropzone ---------- */
.upload-panel { margin-bottom: 2rem; }
.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: .4rem;
    padding: 2.2rem 1rem; border: 2px dashed var(--border); border-radius: var(--radius);
    background: var(--surface); cursor: pointer; text-align: center; transition: .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--surface-2); }
.dropzone-icon { font-size: 1.8rem; }
.dropzone-text { font-size: 1rem; }
.dropzone-hint { color: var(--muted); font-size: .82rem; }

/* ---------- Lista de PDFs ---------- */
.section-title { display: flex; align-items: center; gap: .6rem; font-size: 1.1rem; margin: 0 0 1rem; }
.count {
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--muted); font-size: .8rem; padding: .05rem .5rem; border-radius: 999px;
}
.empty { color: var(--muted); text-align: center; padding: 2.5rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); }

.pdf-grid {
    list-style: none; margin: 0; padding: 0;
    display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.pdf-card {
    position: relative; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; transition: .15s;
}
.pdf-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.pdf-open { display: block; padding: 1rem; color: var(--text); }
.pdf-open:hover { text-decoration: none; }
.pdf-thumb {
    font-size: 2.4rem; text-align: center; padding: 1rem 0;
    background: var(--surface-2); border-radius: 10px; margin-bottom: .8rem;
}
.pdf-meta { display: flex; flex-direction: column; gap: .3rem; }
.pdf-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdf-sub { color: var(--muted); font-size: .8rem; }
.progress { height: 5px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: .3rem; }
.progress-bar { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.pdf-delete { position: absolute; top: .5rem; right: .5rem; margin: 0; }
.btn-del {
    background: rgba(0,0,0,.35); border: 1px solid var(--border); color: #fff;
    width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: .85rem;
    opacity: 0; transition: .15s;
}
.pdf-card:hover .btn-del { opacity: 1; }
.btn-del:hover { background: var(--danger); border-color: var(--danger); }

/* ---------- Viewer ---------- */
.viewer-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.viewer-bar {
    display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.viewer-title { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-tools { display: flex; align-items: center; gap: .5rem; }
.viewer-tools .btn { padding: .4rem .7rem; }
.page-info { color: var(--muted); font-size: .9rem; min-width: 70px; text-align: center; }

.viewer-loading { color: var(--muted); text-align: center; padding: 3rem; }
.pages {
    flex: 1; overflow-y: auto; padding: 1.5rem 0 3rem;
    display: flex; flex-direction: column; align-items: center; gap: 1.2rem;
    background: #0b0d11;
}
.page { position: relative; box-shadow: var(--shadow); background: #fff; border-radius: 2px; }
.page canvas { display: block; border-radius: 2px; }
.page-num {
    position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,.6);
    color: #fff; font-size: .72rem; padding: .1rem .5rem; border-radius: 999px;
}

@media (max-width: 560px) {
    .container { padding: 1rem; }
    .user-email { display: none; }
    .viewer-title { font-size: .95rem; }
}
