
:root {
    --sgs-blue: #0A3F7F;
    --sgs-blue-dark: #082F5D;
    --sgs-orange: #DA512D;
    --sgs-black: #101418;
    --sgs-bg: #F7F8FA;
    --sgs-card: #FFFFFF;
    --sgs-muted: #6C7684;
    --sgs-border: rgba(10, 63, 127, .12);
    --sgs-shadow: 0 18px 45px rgba(8, 47, 93, .10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--sgs-black);
    background: var(--sgs-bg);
    font-family: Inter, Segoe UI, Arial, sans-serif;
}

a {
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 278px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, var(--sgs-blue-dark), var(--sgs-blue));
    color: white;
    padding: 26px 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    box-shadow: var(--sgs-shadow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    font-weight: 800;
    font-size: 1.35rem;
    margin-bottom: 34px;
}

    .brand img {
        width: 58px;
        height: auto;
        background: white;
        border-radius: 16px;
        padding: 8px;
    }

.sidebar .nav-link {
    color: rgba(255,255,255,.82);
    border-radius: 16px;
    padding: 12px 14px;
    margin-bottom: 5px;
    font-weight: 650;
}

    .sidebar .nav-link:hover {
        color: white;
        background: rgba(255,255,255,.12);
    }

.content {
    min-width: 0;
}

.topbar {
    background: rgba(247, 248, 250, .86);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 34px;
    border-bottom: 1px solid var(--sgs-border);
}

    .topbar h1 {
        font-size: 1.75rem;
        font-weight: 800;
        margin: 0;
        color: var(--sgs-blue-dark);
    }

.eyebrow {
    color: var(--sgs-orange);
    text-transform: uppercase;
    letter-spacing: .14em;
    font-weight: 800;
    font-size: .72rem;
}

.page-body {
    padding: 28px 34px 56px;
}

.btn-primary {
    --bs-btn-bg: var(--sgs-blue);
    --bs-btn-border-color: var(--sgs-blue);
    --bs-btn-hover-bg: var(--sgs-blue-dark);
    --bs-btn-hover-border-color: var(--sgs-blue-dark);
}

.btn-warning {
    --bs-btn-bg: var(--sgs-orange);
    --bs-btn-border-color: var(--sgs-orange);
    --bs-btn-color: white;
    --bs-btn-hover-color: white;
}

.btn-outline-primary {
    --bs-btn-color: var(--sgs-blue);
    --bs-btn-border-color: var(--sgs-blue);
    --bs-btn-hover-bg: var(--sgs-blue);
    --bs-btn-hover-border-color: var(--sgs-blue);
}

.panel, .hero-card, .stat-card {
    background: var(--sgs-card);
    border: 1px solid var(--sgs-border);
    border-radius: 24px;
    box-shadow: var(--sgs-shadow);
}

.panel {
    padding: 24px;
}

    .panel.narrow {
        max-width: 960px;
    }

.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

    .panel-title h2 {
        font-size: 1.18rem;
        font-weight: 800;
        margin: 0;
        color: var(--sgs-blue-dark);
    }

.hero-card {
    padding: 26px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: radial-gradient(circle at right top, rgba(218,81,45,.20), transparent 34%), linear-gradient(135deg, var(--sgs-blue), var(--sgs-blue-dark));
    color: white;
}

    .hero-card h2 {
        font-size: 1.8rem;
        font-weight: 850;
        margin: 0;
    }

    .hero-card p {
        color: rgba(255,255,255,.8);
        margin: 6px 0 0;
    }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.stat-card {
    padding: 22px;
}

    .stat-card span {
        display: block;
        color: var(--sgs-muted);
        font-weight: 650;
    }

    .stat-card strong {
        display: block;
        color: var(--sgs-blue-dark);
        font-size: 2.1rem;
        margin-top: 10px;
    }

.search-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

    .search-row .form-control, .search-row .form-select {
        min-height: 44px;
    }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    color: var(--sgs-muted);
}

.table > :not(caption) > * > * {
    padding: 14px 12px;
}

.kanban {
    display: grid;
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    gap: 16px;
    overflow-x: auto;
}

.kanban-column {
    background: #f2f5f9;
    border-radius: 20px;
    padding: 14px;
    min-height: 220px;
}

.kanban-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    margin-bottom: 12px;
}

.kanban-card {
    display: block;
    padding: 14px;
    border-radius: 16px;
    background: white;
    margin-bottom: 12px;
    color: var(--sgs-black);
    border: 1px solid var(--sgs-border);
}

    .kanban-card strong, .kanban-card span, .kanban-card small {
        display: block;
    }

    .kanban-card span {
        color: var(--sgs-blue);
        font-weight: 650;
    }

    .kanban-card small {
        color: var(--sgs-muted);
        margin-top: 4px;
    }

.person-card, .analysis-line, .timeline-item {
    border: 1px solid var(--sgs-border);
    border-radius: 18px;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: white;
}

    .person-card strong, .person-card span, .person-card small, .analysis-line span, .analysis-line strong, .analysis-line small {
        display: block;
    }

    .person-card span, .analysis-line span, .analysis-line small {
        color: var(--sgs-muted);
    }

.chat-layout {
    display: grid;
    grid-template-columns: 330px 1fr;
    gap: 24px;
}

.chat-panel {
    min-height: calc(100vh - 170px);
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow: auto;
    padding: 8px;
    background: linear-gradient(180deg, #f8fbff, #fff);
    border-radius: 20px;
    border: 1px solid var(--sgs-border);
}

.chat-bubble {
    max-width: 78%;
    padding: 14px 16px;
    border-radius: 18px;
    margin: 12px 0;
}

    .chat-bubble.user {
        margin-left: auto;
        background: var(--sgs-blue);
        color: white;
    }

    .chat-bubble.assistant {
        background: white;
        border: 1px solid var(--sgs-border);
    }

.chat-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    margin-top: 16px;
}

.timeline {
    border-left: 3px solid rgba(10,63,127,.15);
    padding-left: 20px;
}

.timeline-item {
    position: relative;
}

    .timeline-item:before {
        content: "";
        position: absolute;
        left: -30px;
        top: 20px;
        width: 14px;
        height: 14px;
        border-radius: 999px;
        background: var(--sgs-orange);
    }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 80% 20%, rgba(218,81,45,.22), transparent 28%), linear-gradient(135deg, var(--sgs-blue-dark), var(--sgs-blue));
    padding: 24px;
}

.login-card {
    width: min(450px, 100%);
    background: rgba(255,255,255,.96);
    border-radius: 30px;
    padding: 36px;
    box-shadow: 0 30px 80px rgba(0,0,0,.25);
}

.login-logo {
    width: 92px;
    background: white;
    padding: 10px;
    border-radius: 22px;
    box-shadow: var(--sgs-shadow);
}

.login-card h1 {
    color: var(--sgs-blue-dark);
    font-weight: 850;
    margin-top: 20px;
}

.login-card p {
    color: var(--sgs-muted);
}

.empty-state, .empty-chat {
    text-align: center;
    color: var(--sgs-muted);
    padding: 40px;
}

.fade-soft {
    opacity: .35;
    transition: opacity .5s ease;
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
    }

    .stats-grid, .kanban, .chat-layout {
        grid-template-columns: 1fr;
    }

    .topbar {
        position: relative;
        padding: 20px;
    }

    .page-body {
        padding: 20px;
    }
}


/* SGS Crédito v2.2 - correção do menu lateral e grupos */
html, body {
    min-height: 100%;
}

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

.sidebar {
    height: 100vh;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.42) rgba(255,255,255,.08);
}

    .sidebar::-webkit-scrollbar {
        width: 9px;
    }

    .sidebar::-webkit-scrollbar-track {
        background: rgba(255,255,255,.08);
        border-radius: 999px;
    }

    .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,.38);
        border-radius: 999px;
    }

.brand {
    flex: 0 0 auto;
    margin-bottom: 22px;
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    padding-bottom: 28px;
}

.nav-group {
    margin: 12px 0 16px;
    padding: 10px 8px 8px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 18px;
    background: rgba(255,255,255,.055);
}

.nav-group-title {
    color: rgba(255,255,255,.68);
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
    padding: 0 8px 7px;
}

.nav-group .nav-link {
    margin-bottom: 3px;
    padding: 10px 12px;
    border-radius: 13px;
    font-size: .93rem;
}

.sidebar .nav-link.active, .sidebar .nav-link:focus {
    color: white;
    background: rgba(255,255,255,.16);
}

.sidebar .nav-link {
    white-space: normal;
    line-height: 1.25;
}

.file-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.file-meta {
    color: var(--sgs-muted);
    font-size: .82rem;
}

.mass-upload-hint {
    color: var(--sgs-muted);
    font-size: .88rem;
    margin-top: .5rem;
}



/* SGS Crédito v2.3 - correção definitiva do menu lateral
   Problema corrigido: grupos aparecendo lado a lado e fundo azul terminando antes do menu completo. */

html,
body {
    min-height: 100%;
}

.app-shell {
    min-height: 100vh;
    align-items: stretch;
}

/* A coluna lateral permanece azul e com rolagem interna quando houver muitos itens. */
.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    background: linear-gradient(180deg, var(--sgs-blue-dark), var(--sgs-blue)) !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.42) rgba(255,255,255,.08);
}

    .sidebar::-webkit-scrollbar {
        width: 9px;
    }

    .sidebar::-webkit-scrollbar-track {
        background: rgba(255,255,255,.08);
        border-radius: 999px;
    }

    .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,.38);
        border-radius: 999px;
    }

    /* Força navegação vertical mesmo que Bootstrap ou regra antiga tente quebrar linha. */
    .sidebar nav,
    .sidebar .nav,
    .sidebar-nav,
    nav.sidebar-nav,
    .sidebar .nav.flex-column {
        width: 100%;
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 0;
        min-height: 0;
        padding-bottom: 32px;
    }

.brand {
    flex: 0 0 auto;
    width: 100%;
    margin-bottom: 22px;
}

.sidebar .nav-link {
    display: block !important;
    width: 100%;
    flex: 0 0 auto !important;
    white-space: normal;
    line-height: 1.25;
}

/* Cada grupo é um bloco vertical, nunca item horizontal. */
.sidebar .nav-group {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    flex: 0 0 auto !important;
    width: 100%;
    min-width: 0;
    margin: 12px 0 16px;
    padding: 10px 8px 8px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 18px;
    background: rgba(255,255,255,.055);
}

.sidebar .nav-group-title {
    display: block;
    width: 100%;
    color: rgba(255,255,255,.70);
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
    padding: 0 8px 7px;
}

.sidebar .nav-group .nav-link {
    margin-bottom: 3px;
    padding: 10px 12px;
    border-radius: 13px;
    font-size: .93rem;
}

.sidebar .nav-link.active,
.sidebar .nav-link:focus {
    color: #fff;
    background: rgba(255,255,255,.16);
}

/* Em telas pequenas o menu deixa de ser sticky, mas continua vertical. */
@media (max-width: 1100px) {
    .sidebar {
        position: relative;
        height: auto;
        min-height: auto;
        max-height: none;
    }
}
