/* =============================================================================
   SISTEMA DE ÍNDICE HÍBRIDO DE SECA (SIHS) — FOLHA DE ESTILOS CENTRAL
   Identidade Visual: Dark Cockpit / Padrão Científico e Agrometeorológico
   Compatível com FastAPI + Jinja2 + Plotly.js (Google Cloud Run)
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. RESET GLOBAL & TIPOGRAFIA
   ----------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #0B0F17;
    color: #F3F4F6;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Scrollbar Sóbria Dark */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #0B0F17;
}
::-webkit-scrollbar-thumb {
    background: #1F2937;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #374151;
}

/* Container de Largura Total */
.app-container {
    width: 100%;
    max-width: 1560px;
    margin: 0 auto;
    padding: 20px 30px;
    flex: 1;
}

/* -----------------------------------------------------------------------------
   2. CABEÇALHO PRINCIPAL SIHS & CÁPSULA DA ESTAÇÃO PILOTO
   ----------------------------------------------------------------------------- */
.sihs-header {
    text-align: center;
    margin-top: 10px;
    margin-bottom: 24px;
}

.sihs-logo {
    font-size: 56px;
    font-weight: 900;
    letter-spacing: 4px;
    color: #FFFFFF;
    margin: 0;
    line-height: 1.1;
}

.sihs-subtitulo {
    font-size: 20px;
    font-weight: 600;
    color: #D1D5DB;
    margin-top: 8px;
    letter-spacing: 0.5px;
}

.estacao-piloto-capsula {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    background: #111827;
    border: 1px solid #1F2937;
    border-radius: 30px;
    padding: 6px 18px;
    margin-top: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.capsula-tag-principal {
    color: #38BDF8;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.capsula-ponto {
    color: #475569;
    font-size: 12px;
}

.capsula-texto {
    color: #CBD5E1;
    font-size: 12px;
    font-weight: 500;
}

.capsula-badge-cad {
    background: rgba(56, 189, 248, 0.15);
    color: #38BDF8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

/* -----------------------------------------------------------------------------
   3. NAVEGAÇÃO PRINCIPAL (ABAS EM PÍLULA)
   ----------------------------------------------------------------------------- */
.nav-pills-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 18px 0 22px 0;
}

.nav-pill-btn {
    background-color: #111827;
    border: 1px solid #1F2937;
    color: #9CA3AF;
    font-weight: 700;
    font-size: 14px;
    height: 42px;
    padding: 0 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-pill-btn:hover {
    background-color: #1F2937;
    color: #F3F4F6;
    border-color: #374151;
}

.nav-pill-btn.active {
    background-color: #1E293B;
    border: 1.5px solid #38BDF8;
    color: #FFFFFF;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.3);
}

.divisor-horizontal {
    border: none;
    border-top: 1px solid #1F2937;
    margin: 16px 0 22px 0;
}

/* -----------------------------------------------------------------------------
   4. PÍLULA SELETORA DE CAMADA (VISÃO PÚBLICA VS. VISÃO TÉCNICA)
   ----------------------------------------------------------------------------- */
.camada-seletor-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 22px;
}

.camada-seletor-capsula {
    display: inline-flex;
    align-items: center;
    background-color: #0F172A;
    border: 1px solid #1E293B;
    border-radius: 30px;
    padding: 4px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.camada-btn {
    border: 1px solid transparent;
    background: transparent;
    padding: 6px 22px;
    border-radius: 24px;
    color: #94A3B8;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.camada-btn:hover {
    background: rgba(255, 255, 255, 0.04);
}

.camada-btn.active {
    background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
    border: 1px solid #38BDF8;
    color: #FFFFFF;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

/* -----------------------------------------------------------------------------
   5. NÍVEL 1: BLOCO UNIFICADO DE SITUAÇÃO ATUAL & DATA BASE
   ----------------------------------------------------------------------------- */
.nivel1-grid {
    display: grid;
    grid-template-columns: 7.35fr 2.65fr;
    gap: 12px;
    margin-bottom: 18px;
}

.status-card {
    background: #181D26;
    border: 1px solid #2D3748;
    border-radius: 10px;
    padding: 12px 20px;
    min-height: 76px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.status-card.verde { border-left: 5px solid #10B981; }
.status-card.vermelho { border-left: 5px solid #EF4444; }
.status-card.ambar { border-left: 5px solid #F59E0B; }

.status-titulo {
    font-size: 14.5px;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.status-titulo.verde { color: #34D399; }
.status-titulo.vermelho { color: #F87171; }
.status-titulo.ambar { color: #FBBF24; }

.status-subtexto {
    color: #D1D5DB;
    font-size: 12.5px;
    margin-top: 3px;
}

.date-card {
    background: #181D26;
    border: 1px solid #2D3748;
    border-radius: 10px;
    padding: 8px 16px;
    min-height: 76px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.date-info-tit {
    color: #9CA3AF;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.date-info-val {
    color: #FFFFFF;
    font-size: 16.5px;
    font-weight: 900;
    font-family: monospace;
    line-height: 1.1;
    margin-top: 2px;
}

.date-info-sub {
    color: #6B7280;
    font-size: 10px;
    margin-top: 2px;
}

.popover-btn {
    background-color: #1F2937;
    border: 1px solid #374151;
    color: #D1D5DB;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.popover-btn:hover {
    border-color: #38BDF8;
    color: #FFFFFF;
    background-color: #2D3748;
}

/* -----------------------------------------------------------------------------
   6. NÍVEL 2: CONSOLE BIVARIADO (RÉGUAS DE IES E IIS)
   ----------------------------------------------------------------------------- */
.bivariado-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 18px;
}

.bivariado-card {
    background: #181D26;
    border: 1px solid #2D3748;
    border-radius: 10px;
    padding: 20px 22px;
    min-height: 230px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.bivariado-topo {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bivariado-tit-interno {
    color: #D1D5DB;
    font-size: 12.5px;
    font-weight: 700;
}

.badge-qualitativo {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.bivariado-num-bloco {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 8px;
}

.bivariado-grande-num {
    color: #FFFFFF;
    font-size: 34px;
    font-weight: 900;
    line-height: 1;
    font-family: monospace;
}

.bivariado-unidade {
    color: #9CA3AF;
    font-size: 12px;
}

.bivariado-descricao {
    color: #9CA3AF;
    font-size: 12px;
    margin-top: 8px;
    line-height: 1.4;
    font-style: italic;
}

/* Pista e Marcadores da Régua */
.regua-wrapper {
    height: 38px;
    position: relative;
    width: 100%;
    margin-top: 14px;
}

.regua-pin-label {
    position: absolute;
    transform: translateX(-50%);
    top: 0px;
    background: #111827;
    color: #FFFFFF;
    font-size: 11.5px;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 5;
    font-family: monospace;
}

.regua-pin-seta {
    position: absolute;
    transform: translateX(-50%);
    top: 20px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    z-index: 5;
}

.regua-barra-ies {
    position: absolute;
    top: 26px;
    left: 0;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #991B1B 0%, #EA580C 31%, #FBBF24 44%, #10B981 71%, #06B6D4 100%);
}

.regua-barra-iis {
    position: absolute;
    top: 26px;
    left: 0;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #06B6D4 0%, #10B981 33.3%, #F59E0B 66.67%, #EF4444 100%);
}

.regua-limiar-traco {
    position: absolute;
    top: 22px;
    height: 16px;
    border-left: 2px dashed #FFFFFF;
    z-index: 4;
}

.regua-rotulos-base {
    display: flex;
    justify-content: space-between;
    color: #9CA3AF;
    font-size: 11px;
    font-family: monospace;
    margin-top: 4px;
}

/* -----------------------------------------------------------------------------
   7. NÍVEL 3: NÓ DE DECISÃO DO SASR (CONVERGÊNCIA BILATERAL)
   ----------------------------------------------------------------------------- */
.sasr-painel-box {
    background: #181D26;
    border: 1px solid #2D3748;
    border-radius: 10px;
    padding: 18px 22px;
    margin-bottom: 22px;
}

.sasr-convergencia-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.trava-box {
    flex: 1.1;
    min-width: 200px;
    background: #111827;
    border: 1px solid #2D3748;
    border-radius: 8px;
    padding: 12px 14px;
    min-height: 118px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.trava-tit {
    color: #9CA3AF;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
}

.trava-val {
    color: #FFFFFF;
    font-size: 17px;
    font-weight: 900;
    margin: 3px 0;
    font-family: monospace;
}

.trava-sub {
    color: #6B7280;
    font-size: 10.5px;
}

.trava-indicador-barra {
    background: #2D3748;
    height: 4px;
    border-radius: 2px;
    width: 100%;
    overflow: hidden;
    margin-top: 6px;
}

.seta-convergente {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 900;
    line-height: 1;
    padding: 0 4px;
}

.no-central-box {
    flex: 1.3;
    min-width: 220px;
    border-radius: 10px;
    padding: 12px 16px;
    min-height: 118px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.no-central-box.ativo {
    background: rgba(239, 68, 68, 0.15);
    border: 1.5px solid #EF4444;
}

.no-central-box.inativo {
    background: #111827;
    border: 1.5px solid #10B981;
}

.no-central-tit {
    color: #9CA3AF;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 2px;
    white-space: nowrap;
}

.no-central-num {
    font-size: 26px;
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 6px;
    font-family: monospace;
}

.sasr-rodape {
    border-top: 1px solid #2D3748;
    margin-top: 12px;
    padding-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.sasr-diagnostico-txt {
    color: #D1D5DB;
    font-size: 12px;
    font-style: italic;
}

/* -----------------------------------------------------------------------------
   8. NÍVEL 4: CONDIÇÕES DE SUPERFÍCIE (GRADE 4 COLUNAS)
   ----------------------------------------------------------------------------- */
.superficie-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.card-superficie {
    background: #181D26;
    border: 1px solid #2D3748;
    border-radius: 10px;
    padding: 20px;
    min-height: 230px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-sup-topo {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.card-sup-tit {
    color: #9CA3AF;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.card-sup-valor-grande {
    color: #FAFAFA;
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
    margin: 6px 0 0 0;
    font-family: monospace;
}

.card-sup-rodape {
    border-top: 1px solid #2D3748;
    padding-top: 14px;
    margin-top: 15px;
}

/* -----------------------------------------------------------------------------
   9. VISÃO TÉCNICA: BANNER SUPERIOR & SUB-ABAS CENTRALIZADAS
   ----------------------------------------------------------------------------- */
.painel-tecnico-header {
    background: #181D26;
    border: 1px solid #2D3748;
    border-left: 4px solid #38BDF8;
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.painel-tecnico-tit {
    color: #FFFFFF;
    font-size: 14.5px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.tecnico-tabs-bar {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tecnico-tab-btn {
    background-color: #111827;
    border: 1px solid #1F2937;
    border-radius: 6px;
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 700;
    color: #9CA3AF;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tecnico-tab-btn:hover {
    color: #F3F4F6;
    background-color: #1F2937;
}

.tecnico-tab-btn.active {
    background-color: #1E293B;
    color: #38BDF8;
    border: 1px solid #38BDF8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

/* -----------------------------------------------------------------------------
   10. MÓDULOS TÉCNICOS: CÁPSULAS, TABELAS E GRADES
   ----------------------------------------------------------------------------- */
.grade-4col {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.card-tecnico-m1 {
    background: #181D26;
    border: 1px solid #2D3748;
    border-radius: 8px;
    padding: 16px;
    min-height: 310px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.capsula-matematica {
    background: #111827;
    border: 1px solid #1F2937;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 8px;
}

.formula-math {
    color: #FFFFFF;
    font-size: 14px;
    font-family: 'Cambria Math', 'Latin Modern Math', Georgia, serif;
    letter-spacing: 0.02em;
}

.tabela-contingencia-real {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    font-size: 13px;
    margin: 6px 0 10px 0;
}

.tabela-contingencia-real th,
.tabela-contingencia-real td {
    padding: 8px 6px;
}

/* -----------------------------------------------------------------------------
   11. RODAPÉ INSTITUCIONAL
   ----------------------------------------------------------------------------- */
.sihs-footer {
    margin-top: 55px;
    border-top: 1px solid #1F2937;
    padding-top: 22px;
    text-align: center;
    margin-bottom: 20px;
}

.sihs-footer-tit {
    color: #9CA3AF;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.sihs-footer-sub {
    color: #6B7280;
    font-size: 12px;
    margin-top: 5px;
}

/* -----------------------------------------------------------------------------
   12. RESPONSIVIDADE (MOBILE & TABLETS)
   ----------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .superficie-grid, .grade-4col {
        grid-template-columns: repeat(2, 1fr);
    }
    .nivel1-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 12px;
    }
    .sihs-logo {
        font-size: 42px;
    }
    .bivariado-grid, .superficie-grid, .grade-4col {
        grid-template-columns: 1fr;
    }
    .sasr-convergencia-grid {
        flex-direction: column;
    }
    .trava-box, .no-central-box {
        width: 100%;
    }
    .seta-convergente {
        transform: rotate(90deg);
        margin: 6px 0;
    }
}