:root {
    --rsc-primary: #0062A6;
    --rsc-secondary: #1A9ADD;
    --rsc-dark: #0f172a;
    --rsc-muted: #64748b;
    --rsc-bg: #f3f7fb;
    --rsc-card: #ffffff;
    --rsc-border: rgba(15, 23, 42, .08);
    --rsc-shadow: 0 18px 50px rgba(15, 23, 42, .10);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--rsc-bg);
    color: var(--rsc-dark);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.btn-primary {
    --bs-btn-bg: var(--rsc-primary);
    --bs-btn-border-color: var(--rsc-primary);
    --bs-btn-hover-bg: #004f86;
    --bs-btn-hover-border-color: #004f86;
    box-shadow: 0 10px 20px rgba(0, 98, 166, .18);
}

.form-control, .form-select {
    border-color: rgba(15, 23, 42, .13);
    border-radius: 14px;
}
.form-control:focus {
    border-color: var(--rsc-secondary);
    box-shadow: 0 0 0 .25rem rgba(26, 154, 221, .15);
}

.admin-shell { min-height: 100vh; display: flex; }
.admin-sidebar {
    width: 290px;
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 24px;
    background: radial-gradient(circle at top left, rgba(26, 154, 221, .5), transparent 30%), linear-gradient(160deg, #06233f, #00528e 52%, #1a9add);
    box-shadow: 10px 0 40px rgba(15, 23, 42, .18);
    z-index: 20;
}
.admin-main { margin-left: 290px; width: calc(100% - 290px); min-height: 100vh; }
.auth-main { width: 100%; min-height: 100vh; }
.content-wrap { padding: 30px; }

.brand-box { display: flex; align-items: center; gap: 14px; }
.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 900;
    letter-spacing: -.08em;
    background: linear-gradient(135deg, var(--rsc-primary), var(--rsc-secondary));
    box-shadow: 0 14px 30px rgba(0, 98, 166, .35);
}
.admin-sidebar .brand-icon { background: rgba(255,255,255,.16); backdrop-filter: blur(8px); }
.brand-title { color: #fff; font-size: 1.1rem; font-weight: 800; line-height: 1.1; }
.brand-subtitle { color: rgba(255,255,255,.65); font-size: .82rem; }
.login-page .brand-title { color: var(--rsc-dark); }
.login-page .brand-subtitle { color: var(--rsc-muted); }

.sidebar-nav { margin-top: 38px; display: grid; gap: 10px; }
.nav-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 13px 14px;
    border-radius: 16px;
    color: rgba(255,255,255,.78);
    text-decoration: none;
    transition: .2s ease;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.14); color: #fff; transform: translateX(3px); }
.nav-ico { width: 28px; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 16px; border-radius: 20px; background: rgba(255,255,255,.12); backdrop-filter: blur(10px); }

.topbar {
    min-height: 110px;
    padding: 28px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: rgba(255, 255, 255, .75);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--rsc-border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h1 { margin: 0; font-size: clamp(1.4rem, 2vw, 2rem); font-weight: 850; letter-spacing: -.03em; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; color: var(--rsc-secondary); font-size: .75rem; font-weight: 800; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(380px, .75fr);
    gap: 36px;
    padding: 42px;
    background: radial-gradient(circle at 18% 20%, rgba(26,154,221,.24), transparent 28%), radial-gradient(circle at 80% 80%, rgba(0,98,166,.18), transparent 25%), #f8fbff;
}
.login-hero { display: flex; flex-direction: column; justify-content: center; max-width: 760px; }
.login-hero h1 { font-size: clamp(2.2rem, 5vw, 4.8rem); line-height: .98; font-weight: 900; letter-spacing: -.07em; margin: 0 0 24px; }
.login-hero p { font-size: 1.2rem; color: var(--rsc-muted); max-width: 620px; }
.login-pills { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.login-pills span { padding: 10px 14px; background: #fff; border: 1px solid var(--rsc-border); border-radius: 999px; font-weight: 700; color: #334155; }
.login-card { align-self: center; border-radius: 28px; overflow: hidden; }
.helper-box { background: #f1f7fd; color: #334155; border: 1px solid rgba(26,154,221,.18); border-radius: 18px; padding: 16px; font-size: .92rem; }

.metric-card, .provider-card, .empty-state, .info-panel {
    background: var(--rsc-card);
    border: 1px solid var(--rsc-border);
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}
.metric-card { padding: 22px; min-height: 140px; }
.metric-label { color: var(--rsc-muted); font-weight: 800; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }
.metric-value { margin-top: 8px; font-size: 2.1rem; font-weight: 900; letter-spacing: -.06em; }
.metric-hint { color: var(--rsc-muted); font-size: .9rem; }
.code-sm { font-size: 1.45rem; font-family: Consolas, Monaco, monospace; }
.endpoint-box { border: 1px solid var(--rsc-border); border-radius: 18px; padding: 12px 16px; min-width: 220px; background: #f8fafc; }
.endpoint-box span, .test-box span { display: block; color: var(--rsc-muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.endpoint-box code, .test-box code { color: var(--rsc-primary); font-size: 1rem; font-weight: 800; }

.provider-card { padding: 26px; height: 100%; position: relative; overflow: hidden; }
.provider-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: #94a3b8; }
.provider-card.is-on::before { background: #16a34a; }
.provider-card.is-off::before { background: #dc2626; }
.provider-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.provider-avatar {
    width: 58px;
    height: 58px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 900;
    background: linear-gradient(135deg, #334155, #64748b);
    flex: 0 0 auto;
}
.provider-avatar.openai { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.provider-avatar.gemini { background: linear-gradient(135deg, #7c3aed, #1a9add); }
.provider-avatar.anthropic { background: linear-gradient(135deg, #b45309, #f59e0b); }
.provider-avatar.fake { background: linear-gradient(135deg, #475569, #94a3b8); }
.provider-head h3 { margin: 0; font-size: 1.25rem; font-weight: 850; }
.provider-code { font-family: Consolas, Monaco, monospace; color: var(--rsc-muted); font-size: .88rem; }
.provider-desc { color: var(--rsc-muted); min-height: 48px; }
.provider-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0 22px; }
.provider-grid > div { background: #f8fafc; border: 1px solid rgba(15,23,42,.06); border-radius: 16px; padding: 13px; min-width: 0; }
.provider-grid span { display: block; font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--rsc-muted); }
.provider-grid strong { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-mask { font-family: Consolas, Monaco, monospace; font-size: .88rem; }
.provider-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.provider-actions form { margin: 0; }
.empty-state { padding: 48px; text-align: center; }
.empty-icon { font-size: 3rem; }

.back-link { text-decoration: none; color: var(--rsc-primary); font-weight: 800; }
.admin-form .form-label { font-weight: 800; color: #334155; }
.info-panel { padding: 28px; top: 138px; }
.info-panel h3 { font-weight: 850; }
.info-panel p, .info-panel li { color: var(--rsc-muted); }
.info-panel code { color: var(--rsc-primary); }
.test-box { background: #f8fafc; border: 1px solid var(--rsc-border); border-radius: 18px; padding: 16px; margin-top: 18px; }
.test-box small { display: block; color: var(--rsc-muted); margin-top: 6px; }
.min-w-0 { min-width: 0; }

@media (max-width: 991px) {
    .admin-sidebar { position: relative; width: 100%; min-height: auto; border-radius: 0 0 26px 26px; }
    .admin-shell { display: block; }
    .admin-main { margin-left: 0; width: 100%; }
    .topbar { position: relative; flex-direction: column; align-items: flex-start; }
    .login-page { grid-template-columns: 1fr; padding: 24px; }
    .login-hero h1 { font-size: 2.35rem; }
}

@media (max-width: 575px) {
    .content-wrap { padding: 20px; }
    .provider-grid { grid-template-columns: 1fr; }
    .topbar-actions { flex-wrap: wrap; }
}

/* =========================
   Setup / Instalação
   ========================= */
.setup-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(26, 154, 221, .35), transparent 35%),
        radial-gradient(circle at top right, rgba(0, 98, 166, .30), transparent 35%),
        linear-gradient(135deg, #06152a 0%, #0a2540 45%, #f5f8fc 45%, #eef4fb 100%);
}

.setup-shell {
    min-height: 100vh;
}

.setup-hero {
    color: #fff;
    padding: 42px clamp(20px, 4vw, 60px) 34px;
    max-width: 1180px;
    margin: 0 auto;
}

.setup-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 28px;
}

.setup-hero h1 {
    max-width: 760px;
    font-size: clamp(2rem, 4vw, 4rem);
    font-weight: 850;
    letter-spacing: -.05em;
    line-height: .98;
    margin-bottom: 18px;
}

.setup-hero p {
    color: rgba(255, 255, 255, .78);
    max-width: 760px;
    font-size: 1.05rem;
}

.setup-hero code {
    color: #fff;
    background: rgba(255, 255, 255, .12);
    border-radius: 8px;
    padding: 2px 6px;
}

.setup-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.setup-pills span {
    border: 1px solid rgba(255, 255, 255, .20);
    background: rgba(255, 255, 255, .10);
    color: #fff;
    border-radius: 999px;
    padding: 8px 13px;
    font-size: .88rem;
    backdrop-filter: blur(10px);
}

.setup-content {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 clamp(20px, 4vw, 60px) 50px;
}

.setup-card,
.setup-status-card {
    border-radius: 24px;
}

.setup-status-card {
    min-height: 118px;
    padding: 20px;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 18px 50px rgba(10, 37, 64, .12);
    border: 1px solid rgba(255, 255, 255, .70);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setup-status-card span {
    font-size: 1.5rem;
}

.setup-status-card strong {
    font-size: 1rem;
    color: #102033;
}

.setup-status-card small {
    color: #718096;
}

.setup-status-card.ok {
    border-left: 5px solid #16a34a;
}

.setup-status-card.warn {
    border-left: 5px solid #f59e0b;
}

.setup-status-card.danger {
    border-left: 5px solid #dc2626;
}

.setup-checks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 18px;
    padding: 16px;
    border-radius: 18px;
    background: #f6f9fd;
    border: 1px solid #e6eef8;
}

.status-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #eef2f7;
}

.status-line span {
    color: #64748b;
}

.migration-list {
    display: grid;
    gap: 8px;
}

.migration-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 12px;
    padding: 10px 12px;
    border: 1px solid #e8eef6;
    background: #f8fafc;
}

.migration-item.done {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.migration-item.pending {
    background: #fffbeb;
    border-color: #fde68a;
}

.next-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 13px 0;
    border-bottom: 1px solid #eef2f7;
}

.next-step:last-of-type {
    border-bottom: 0;
}

.next-step span {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #0062A6;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex: 0 0 auto;
}

@media (max-width: 767px) {
    .setup-checks {
        grid-template-columns: 1fr;
    }
}


/* V4 modules */
.code-input, .result-json { font-family: Consolas, Monaco, 'Courier New', monospace; }
.result-json { background:#0f172a; color:#dbeafe; border-radius:18px; padding:18px; min-height:280px; max-height:640px; overflow:auto; font-size:.9rem; }
.chat-row { display:flex; margin-bottom:14px; }
.chat-user { justify-content:flex-end; }
.chat-assistant { justify-content:flex-start; }
.chat-bubble { max-width:82%; padding:14px 16px; border-radius:18px; background:#f1f5f9; box-shadow:0 10px 30px rgba(15,23,42,.06); }
.chat-user .chat-bubble { background:#0062A6; color:#fff; }
.chat-user .chat-bubble .text-muted { color:rgba(255,255,255,.75)!important; }
.table td, .table th { vertical-align: middle; }
.sidebar-nav { overflow-y:auto; padding-right:4px; }
.sidebar-nav::-webkit-scrollbar { width:6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background:rgba(255,255,255,.25); border-radius:99px; }

/* V5 - usuários e perfil */
.min-w-0 { min-width: 0; }
.user-avatar-sm,
.user-avatar-md,
.topbar-profile,
.profile-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: 0 0 auto;
    background: linear-gradient(135deg, #0062A6, #1A9ADD);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 10px 25px rgba(0, 98, 166, .18);
}
.user-avatar-sm {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,.28);
}
.user-avatar-md {
    width: 46px;
    height: 46px;
    border-radius: 16px;
}
.user-avatar-sm img,
.user-avatar-md img,
.topbar-profile img,
.profile-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.user-avatar-initial { letter-spacing: .03em; }
.topbar-profile {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    text-decoration: none;
    border: 2px solid #fff;
}
.profile-preview {
    width: 132px;
    height: 132px;
    border-radius: 34px;
    font-size: 3.2rem;
}
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 800;
}
.status-pill.ok {
    color: #166534;
    background: #dcfce7;
}
.status-pill.off {
    color: #991b1b;
    background: #fee2e2;
}
.stat-card.primary-soft {
    background: linear-gradient(135deg, #eff6ff, #ffffff);
}
.stat-card.warning {
    background: linear-gradient(135deg, #fff7ed, #ffffff);
}
.section-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #dbe5f1, transparent);
}
@media (max-width: 991px) {
    .topbar-profile { display: none; }
}
