/* ──────────────────────────────────────────────
   Mais Leite — Painel Administrativo
   ────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --brand: #c41e3a;
    --brand-dark: #a01830;
    --dark: #0d1b2a;
    --dark2: #162333;
    --dark3: #1e2f42;
    --text: #1a1a2e;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f6f8fa;
    --white: #ffffff;
    --green: #059669;
    --blue: #2563eb;
    --amber: #d97706;
    --sidebar-w: 240px;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; }

/* ── TELA DE ACESSO ─────────────────────────── */
.access-screen {
    min-height: 100dvh;
    display: flex;
    position: relative;
}

/* ── Painel esquerdo (branding) ───────────────── */
.access-left {
    flex: 1;
    background: #0F172A;
    background-image:
        radial-gradient(ellipse 70% 60% at 30% 20%, rgba(185,28,28,0.28) 0%, transparent 70%),
        radial-gradient(ellipse 50% 50% at 85% 85%, rgba(185,28,28,0.13) 0%, transparent 60%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem 3.5rem;
    position: relative;
    overflow: hidden;
    color: #fff;
}

/* Grid pattern overlay */
.access-left::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.028) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.028) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

.access-brand-content { position: relative; z-index: 1; }

.access-logo { margin-bottom: 3.5rem; }

.access-logo img {
    height: 42px;
}

.access-hero { max-width: 380px; }

.access-hero h1 {
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.18;
    margin-bottom: 1rem;
    color: #fff;
}

.access-hero h1 span { color: #F87171; }

.access-hero > p {
    font-size: 0.92rem;
    color: #94A3B8;
    line-height: 1.75;
    max-width: 340px;
}

/* Feature list */
.access-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 1.75rem;
}

.access-feature {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: #CBD5E1;
}

.access-feature-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #F87171;
    flex-shrink: 0;
}

/* Portal buttons */
.access-portals {
    position: relative; z-index: 1;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.access-portals > p {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    margin-bottom: 0.25rem;
}

.portal-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.875rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.portal-btn:hover {
    background: rgba(255,255,255,0.09);
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

.portal-btn .pb-icon {
    width: 28px; height: 28px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.82rem; flex-shrink: 0;
}

.portal-btn.pb-site .pb-icon { background: rgba(196,30,58,0.2); color: #e87b8a; }
.portal-btn.pb-saas .pb-icon { background: rgba(37,99,235,0.2);  color: #7cacfa; }

.portal-btn .pb-meta { display: flex; flex-direction: column; line-height: 1.25; font-size: 0.8rem; }
.portal-btn .pb-meta small { font-size: 0.67rem; font-weight: 400; color: rgba(255,255,255,0.42); }

/* Decorative SVG */
.access-ilu {
    position: absolute;
    right: -40px; top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    opacity: 0.055;
    pointer-events: none;
}

/* Left footer */
.access-brand-footer {
    font-size: 0.72rem;
    color: #475569;
    margin-top: 1rem;
    position: relative; z-index: 1;
}

/* ── Painel direito (formulário) ──────────────── */
.access-right {
    width: 480px;
    flex-shrink: 0;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    border-left: 1px solid var(--border);
}

.login-box {
    width: 100%;
    max-width: 340px;
}

.login-box h2 {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0.375rem;
    color: var(--text);
}

.login-box p.login-sub {
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.55;
    margin-bottom: 1.75rem;
}

/* Security badges */
.security-badges {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.sec-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 4px 10px;
}

/* ── Password toggle ──────────────────────────── */
.input-pw-wrap { position: relative; }
.input-pw-wrap input { width: 100%; padding-right: 3rem; }
.pw-toggle {
    position: absolute; right: 0.75rem; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: var(--muted); cursor: pointer;
    display: flex; align-items: center;
    padding: 3px; transition: color 0.15s;
}
.pw-toggle:hover { color: var(--text); }

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}

.form-group input {
    width: 100%;
    padding: 0.7rem 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.18s, box-shadow 0.18s;
    outline: none;
}

.form-group input::placeholder { color: var(--muted); opacity: 0.7; }

.form-group input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(196,30,58,0.08);
    background: var(--white);
}

.btn-login {
    width: 100%;
    padding: 0.75rem;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    letter-spacing: 0.01em;
    transition: background 0.18s, transform 0.12s, box-shadow 0.18s;
    box-shadow: 0 1px 2px rgba(196,30,58,0.2);
    margin-top: 0.25rem;
}

.btn-login:hover {
    background: var(--brand-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(196,30,58,0.3);
}

.btn-login:active { transform: translateY(0); box-shadow: none; }

.btn-login:disabled {
    background: #CBD5E1;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.login-error {
    display: none;
    align-items: center;
    gap: 8px;
    margin-bottom: 1.25rem;
    padding: 0.7rem 0.875rem;
    background: #FEF2F2;
    border: 1px solid #FCA5A5;
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--brand);
    font-weight: 500;
}

.login-error.show { display: flex; }

/* Setup first time */
.setup-note {
    margin-top: 1.5rem;
    padding: 0.875rem 1rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #92400e;
    line-height: 1.5;
}

/* ── LAYOUT PRINCIPAL ───────────────────────── */
.admin-layout {
    display: none;
    min-height: 100dvh;
}

.admin-layout.active {
    display: flex;
    min-height: 100dvh;
}

/* ── SIDEBAR ─────────────────────────────────── */
.sidebar {
    background: var(--dark);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    width: var(--sidebar-w);
    transition: width 0.25s cubic-bezier(0.16,1,0.3,1);
    will-change: width;
    flex-shrink: 0;
}

.sidebar-logo {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo img {
    height: 36px;
}

.logo-mini { display: none; }

.sidebar.collapsed .logo-full { display: none; }
.sidebar.collapsed .logo-mini { display: block; width: 32px; height: 32px; object-fit: contain; }

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.nav-section-label {
    padding: 0.75rem 1.25rem 0.375rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.28);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    color: rgba(255,255,255,0.55);
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 0;
    transition: color 0.2s, background 0.2s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item i {
    width: 18px;
    text-align: center;
    font-size: 0.85rem;
}

.nav-item:hover {
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.04);
}

.nav-item.active {
    color: var(--white);
    background: var(--brand);
    border-radius: 8px;
    margin: 0 0.625rem;
    padding-left: 0.625rem;
    padding-right: 0.625rem;
    width: calc(100% - 1.25rem);
}

/* Sub-menu de Configurações */
.nav-sub {
    display: none;
    overflow: hidden;
}

.nav-sub.show { display: block; }

.nav-sub-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 1rem 0.45rem 2.75rem;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.45);
    border-radius: 6px;
    margin: 0 0.625rem;
    transition: color .15s, background .15s;
}

.nav-sub-item:hover {
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.04);
}

.nav-sub-item i { font-size: 0.72rem; width: 14px; text-align: center; }

.sidebar.collapsed .nav-sub { display: none !important; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(196,30,58,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e87b8a;
    font-size: 0.8rem;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-info strong {
    display: block;
    font-size: 0.82rem;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info small {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.35);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 7px;
    border: 1px solid rgba(255,255,255,0.08);
    background: none;
    color: rgba(255,255,255,0.4);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(196,30,58,0.1);
    border-color: rgba(196,30,58,0.25);
    color: #e87b8a;
}

/* ── CONTEÚDO PRINCIPAL ─────────────────────── */
.main-content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    background: var(--bg);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-date {
    font-size: 0.8rem;
    color: var(--muted);
}

/* ── VIEWS ──────────────────────────────────── */
.view { display: none; padding: 2rem; }
.view.active { display: block; }

/* ── CARDS DE MÉTRICAS ───────────────────────── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-icon {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.metric-icon.red   { background: #fff0f2; color: var(--brand); }
.metric-icon.green { background: #ecfdf5; color: var(--green); }
.metric-icon.blue  { background: #eff6ff; color: var(--blue); }
.metric-icon.amber { background: #fffbeb; color: var(--amber); }

.metric-label {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 500;
}

.metric-value {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text);
    line-height: 1;
}

.metric-delta {
    font-size: 0.75rem;
    font-weight: 600;
}

.metric-delta.up   { color: var(--green); }
.metric-delta.down { color: var(--brand); }

/* ── CARDS DE CONTEÚDO ───────────────────────── */
.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
}

.card-header .card-meta {
    font-size: 0.75rem;
    color: var(--muted);
}

.card-body { padding: 1.5rem; }

.chart-wrap {
    position: relative;
    height: 240px;
}

/* ── TABELA DE PÁGINAS ───────────────────────── */
.pages-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.pages-table th {
    text-align: left;
    padding: 0.625rem 1rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.pages-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.pages-table tr:last-child td { border-bottom: none; }
.pages-table tr:hover td { background: var(--bg); }

.page-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}

.page-badge.active { background: #ecfdf5; color: var(--green); }

.bar-mini {
    height: 6px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    width: 80px;
}

.bar-mini-fill {
    height: 100%;
    background: var(--brand);
    border-radius: 99px;
}

/* ── RANKING PAGES ───────────────────────────── */
.page-rank-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.rank-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.rank-item:last-child { border-bottom: none; }

.rank-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--muted);
    flex-shrink: 0;
}

.rank-num.top { background: var(--brand); border-color: var(--brand); color: var(--white); }

.rank-info { flex: 1; min-width: 0; }
.rank-info strong { display: block; font-size: 0.82rem; font-weight: 600; }
.rank-info small { font-size: 0.72rem; color: var(--muted); }

.rank-count {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
}

/* ── SEÇÃO ANALYTICS ─────────────────────────── */
.analytics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.analytics-header h2 {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.period-selector {
    display: flex;
    gap: 0.375rem;
}

.period-btn {
    padding: 0.4rem 0.875rem;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--white);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    transition: all 0.2s;
}

.period-btn:hover { border-color: var(--brand); color: var(--brand); }
.period-btn.active { background: var(--brand); border-color: var(--brand); color: var(--white); }

.analytics-grid-full {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.analytics-bottom {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

/* ── SEÇÃO PÁGINAS (CMS) ─────────────────────── */
.pages-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.page-item {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1.25rem;
    box-shadow: var(--shadow);
    transition: border-color 0.2s;
}

.page-item:hover { border-color: var(--brand); }

.page-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #fff0f2;
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.page-info strong {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.page-info small { font-size: 0.78rem; color: var(--muted); }

.page-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.4rem 0.875rem;
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 600;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.btn-sm.outline {
    background: none;
    border: 1.5px solid var(--border);
    color: var(--text);
}

.btn-sm.outline:hover { border-color: var(--brand); color: var(--brand); }

.btn-sm.primary {
    background: var(--brand);
    color: var(--white);
}

.btn-sm.primary:hover { background: var(--brand-dark); }

/* ── SEÇÃO CONFIGURAÇÕES ─────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

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

.settings-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.settings-card-header i {
    width: 32px;
    height: 32px;
    border-radius: 7px;
    background: #fff0f2;
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.settings-card-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
}

.settings-card-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.settings-card-body .form-group { margin-bottom: 0; }

.input-copy {
    display: flex;
    gap: 0.5rem;
}

.input-copy input { flex: 1; }

.btn-copy {
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    background: var(--bg);
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-copy:hover { border-color: var(--brand); color: var(--brand); }

.settings-note {
    padding: 0.875rem 1rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    font-size: 0.78rem;
    color: #92400e;
    line-height: 1.5;
}

.settings-note code {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
}

.btn-save {
    padding: 0.7rem 1.5rem;
    background: var(--brand);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    transition: background 0.2s, transform 0.15s;
    align-self: flex-start;
}

.btn-save:hover { background: var(--brand-dark); }
.btn-save:active { transform: scale(0.98); }

.save-feedback {
    display: none;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--green);
    align-self: center;
}

.save-feedback.show { display: block; }

/* ── SQL SETUP ───────────────────────────────── */
.sql-block {
    background: #0d1b2a;
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.75rem;
    color: #7dd3fc;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
    white-space: pre;
}

/* ── EMPTY STATE ─────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
    opacity: 0.35;
}

.empty-state p {
    font-size: 0.88rem;
    line-height: 1.6;
    max-width: 320px;
    margin: 0 auto;
}

/* ── BADGES DE ROLE/STATUS ───────────────────── */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .65rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
}
.role-badge.admin  { background: #fff0f2; color: var(--brand); }
.role-badge.user   { background: #eff6ff; color: var(--blue); }
.role-badge.active { background: #ecfdf5; color: var(--green); }
.role-badge.off    { background: #f3f4f6; color: #9ca3af; }

/* ── ACTION BUTTONS (tabela) ─────────────────── */
.tbl-actions { display: flex; gap: .375rem; }
.tbl-btn {
    width: 30px; height: 30px;
    border-radius: 7px;
    border: 1.5px solid var(--border);
    background: none;
    display: flex; align-items: center; justify-content: center;
    font-size: .78rem;
    color: var(--muted);
    cursor: pointer;
    transition: all .2s;
}
.tbl-btn:hover          { border-color: var(--brand); color: var(--brand); background: #fff0f2; }
.tbl-btn.danger:hover   { border-color: #ef4444; color: #ef4444; background: #fef2f2; }
.tbl-btn.success:hover  { border-color: var(--green); color: var(--green); background: #ecfdf5; }

/* ── TOAST ───────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--dark);
    color: var(--white);
    padding: 0.875rem 1.25rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast i { color: #4ade80; }

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 1024px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .content-grid { grid-template-columns: 1fr; }
    .analytics-grid-full { grid-template-columns: 1fr; }
    .analytics-bottom { grid-template-columns: 1fr 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
}

/* ── Avatar na tela de login ─────────────────── */
.login-avatar-wrap {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-60%);
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 420px;
    pointer-events: none;
}

.login-avatar-img {
    width: 100%;
    max-height: 520px;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 10px 32px rgba(0,0,0,0.55));
}

.login-bubble {
    position: relative;
    background: #fff;
    border-radius: 20px;
    padding: 16px 22px;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.7;
    text-align: center;
    letter-spacing: -0.01em;
    box-shadow: 0 6px 28px rgba(0,0,0,0.25);
    margin-bottom: 12px;
    min-height: 62px;
    min-width: 210px;
    white-space: pre-wrap;
}

.login-bubble::after {
    content: '';
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    border: 13px solid transparent;
    border-top-color: #fff;
    border-bottom: 0;
}

.bubble-cursor {
    display: inline;
    color: #e11d48;
    font-weight: 700;
    animation: bubbleBlink 0.7s step-end infinite;
}

@keyframes bubbleBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.saas-mobile-btn {
    display: none;
}

@media (max-width: 900px) {
    .access-left { display: none; }
    .access-right { width: 100%; min-height: 100dvh; border-left: none; }

    .saas-mobile-btn {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        margin-top: 1.25rem;
        width: 100%;
        justify-content: center;
        padding: 0.7rem 1.25rem;
        border-radius: 8px;
        font-size: 0.88rem;
        font-weight: 600;
        text-decoration: none;
        background: rgba(196,30,58,0.08);
        color: #c41e3a;
        border: 1.5px solid rgba(196,30,58,0.22);
        transition: background 0.2s ease, border-color 0.2s ease;
    }

    .saas-mobile-btn:hover {
        background: rgba(196,30,58,0.14);
        border-color: rgba(196,30,58,0.38);
    }
}

@media (max-width: 768px) {

    .admin-layout.active {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        z-index: 100;
        transition: left 0.3s ease, width 0.25s cubic-bezier(0.16,1,0.3,1);
        width: 240px !important;
        height: 100dvh;
    }

    .sidebar.open { left: 0 !important; }
    .sidebar.collapsed { left: -100%; }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }

    .sidebar-overlay.show { display: block; }

    .mobile-menu-btn { display: flex !important; }
    .sidebar-collapse-btn { display: none; }

    .topbar { padding: 1rem; }
    .view { padding: 1rem; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .analytics-bottom { grid-template-columns: 1fr; }
    .topbar-user-name { display: none !important; }
}

/* ── SIDEBAR: USER CARD ─────────────────────────── */
.sidebar-user-card {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.s-avatar {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--brand);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.82rem; font-weight: 800;
    color: #fff; flex-shrink: 0;
    letter-spacing: -0.01em;
}

.sidebar-user-card .user-info strong { font-size: .85rem; }
.sidebar-user-card .user-info small  { font-size: .72rem; }

/* ── SIDEBAR: COLLAPSE ──────────────────────────── */
.sidebar.collapsed { width: 64px; }

.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .sidebar-user-card .user-info,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-collapse-label { display: none !important; }

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.625rem;
    margin: 0 0.375rem;
    width: calc(100% - 0.75rem);
}

.sidebar.collapsed .nav-item i { width: auto; }

.sidebar.collapsed .sidebar-user-card {
    justify-content: center;
    padding: 0.875rem;
}

.sidebar.collapsed .sidebar-collapse-btn {
    justify-content: center;
    padding: 0.875rem;
}

.sidebar.collapsed .sidebar-logo img { width: 28px; }

.sidebar-collapse-btn {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 0.875rem 1.375rem;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.07);
    background: none;
    color: rgba(255,255,255,0.4);
    font-size: 0.8rem; font-weight: 500;
    width: 100%; text-align: left; cursor: pointer;
    transition: color 0.2s, background 0.2s;
    font-family: inherit;
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    color: rgba(255,255,255,.75);
    background: rgba(255,255,255,.03);
}

/* ── TOPBAR: AÇÕES DO USUÁRIO ───────────────────── */
.topbar-icon-btn {
    width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--muted); font-size: 0.88rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s;
    flex-shrink: 0;
}

.topbar-icon-btn:hover { border-color: var(--brand); color: var(--text); }

.topbar-user-wrap { position: relative; }

.topbar-user-btn {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.3rem 0.75rem 0.3rem 0.375rem;
    border-radius: 99px;
    background: var(--bg); border: 1px solid var(--border);
    cursor: pointer; transition: border-color 0.2s;
    font-family: inherit;
}

.topbar-user-btn:hover { border-color: rgba(196,30,58,0.45); }

.topbar-user-btn .t-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 800;
}

.topbar-user-btn .t-name {
    font-size: .83rem; font-weight: 600; color: var(--text);
}

.topbar-user-btn .t-chevron {
    font-size: .6rem; color: var(--muted);
    transition: transform 0.2s;
}

.topbar-user-btn.open .t-chevron { transform: rotate(180deg); }

/* ── USER DROPDOWN ──────────────────────────────── */
.user-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    min-width: 210px;
    background: var(--white); border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 32px rgba(0,0,0,0.14);
    z-index: 300; overflow: hidden;
    opacity: 0; transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.16,1,0.3,1),
                transform 0.2s cubic-bezier(0.16,1,0.3,1);
}

.user-dropdown.show {
    opacity: 1; transform: translateY(0); pointer-events: auto;
}

.user-dropdown-header {
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.user-dropdown-header strong { display: block; font-size: .88rem; font-weight: 700; }
.user-dropdown-header small  { font-size: .72rem; color: var(--muted); }

.user-dropdown-item {
    display: flex; align-items: center; gap: .625rem;
    width: 100%; padding: .75rem 1.25rem;
    border: none; background: none;
    font-family: inherit; font-size: .85rem;
    color: var(--text); cursor: pointer;
    transition: background .15s; text-align: left;
}

.user-dropdown-item:hover { background: var(--bg); }

.user-dropdown-item.danger { color: var(--brand); }
.user-dropdown-item.danger:hover { background: #fff0f2; }

/* ── REMEMBER ME ────────────────────────────────── */
.remember-row {
    display: flex; align-items: center; gap: .5rem;
    margin-bottom: 1.25rem;
}

.remember-row input[type="checkbox"] {
    width: 15px; height: 15px;
    accent-color: var(--brand);
    cursor: pointer; flex-shrink: 0;
}

.remember-row label {
    font-size: .82rem; color: var(--muted);
    cursor: pointer; font-weight: 500;
    user-select: none;
}

/* ── DARK MODE ──────────────────────────────────── */
html.dark {
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #1e3448;
    --bg: #091624;
    --white: #0d1b2a;
    --shadow: 0 1px 4px rgba(0,0,0,0.35), 0 4px 16px rgba(0,0,0,0.25);
}

html.dark .access-right { background: #0d1b2a; }

html.dark .form-group input {
    background: #091624; color: var(--text); border-color: var(--border);
}

html.dark .form-group input:focus { background: #091624; }

html.dark .login-box h2 { color: var(--text); }
html.dark .login-box .login-sub { color: var(--muted); }

html.dark .user-dropdown,
html.dark .metric-card,
html.dark .card,
html.dark .settings-card,
html.dark .page-item { background: #111f2e; border-color: var(--border); }

html.dark .topbar { background: #0d1b2a; border-color: var(--border); }
html.dark .topbar-user-btn { background: #091624; }
html.dark .topbar-icon-btn { background: #0d1b2a; }
html.dark .period-btn { background: #0d1b2a; border-color: var(--border); color: var(--muted); }
html.dark .period-btn.active { background: var(--brand); color: #fff; }
html.dark .pages-table th { background: #091624; }
html.dark .pages-table tr:hover td { background: #091624; }
html.dark .tbl-btn { border-color: var(--border); }
html.dark select { background: #091624; color: var(--text); border-color: var(--border); }

/* mobile menu button */
.mobile-menu-btn {
    background: none; border: none;
    font-size: 1.1rem; color: var(--muted);
    cursor: pointer; padding: .25rem;
    display: none;
}
