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

html, body {
    height: 100%;
    overflow-y: auto;
}

body {
    display: flex;
    flex-direction: column;
    background: #f3f8f2;
    color: #07111f;
    font-family: 'Segoe UI', sans-serif;
    font-size: 15px;
}

/* =======================================
   ESTRUTURA GERAL (Layout principal)
   ======================================= */
.topbar {
    background: linear-gradient(180deg, #07111f 0%, #0c1828 100%);
    display: flex;
    align-items: center;
    min-height: 58px;
    border-bottom: 2px solid #c9a25d;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);

    gap: 2px;
    padding: 0 10px;
}

.content {
    flex: 1;
    overflow: auto; /* Melhor que scroll para não forçar barra vazia */
    padding: 15px;
    position: relative;
    background: #e9f0d3;
}

.bottom-bar {
    display: flex;
    background: #e6ebe5;
    border-top: 1px solid #cbd5e1;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 99999;
}

/* =======================================
   Navegação (Tabs)
   ======================================= */
.top-tab {
    background: none;
    border: none;
    color: #d1d5db;
    padding: 14px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: 0.2s;
}

.top-tab:hover {
    color: #ffffff;
}

.top-tab-ia {
    color: #c9a25d !important;
    font-weight: 700;
}

.top-tab-ia:hover {
    color: #e6c27a !important;
}

.top-tab:hover {
    background: rgba(201, 162, 93, 0.08);
    color: #c9a25d;
}

.top-tab.active {
    color: #c9a25d;
    border-bottom: 3px solid #c9a25d;
    background: rgba(201, 162, 93, 0.08);
}

.bottom-tab {
    background: none;
    border: none;
    padding: 12px 18px;
    cursor: pointer;
    color: #1e3a8a;
    font-weight: 600;
}

.bottom-tab:hover {
    color: #07111f;
}

.bottom-tab.active {
    color: #07111f;
    background: #c9a25d;
    font-weight: bold;
}

/* =======================================
   Marca (Brand e Logo)
   ======================================= */
.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 230px;
    padding: 0 15px;
    border-right: 1px solid rgba(201, 162, 93, 0.25);
}

.brand img {
    width: 58px;
    height: 58px;
    object-fit: contain;
}

.brand-text .nome {
    display: block;
    color: #c9a25d;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    font-family: Georgia, serif;
}

.brand-text .sub {
    display: block;
    color: #d6b06a;
    font-size: 11px;
    letter-spacing: 2px;
    line-height: 1;
    margin-top: 3px;
}

/* =======================================
   Componentes de Tela
   ======================================= */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

.card {
    background: white;
    border: 1px solid #d1d5db;
    padding: 20px;
    margin-bottom: 15px;
}

.toolbar {
    position: sticky;
    top: 0;
    z-index: 99999;
    display: flex;
    gap: 10px;
    padding: 12px 0;
    background: #f3f8f2;
    box-shadow: 0 10px 0 #f3f4f6; /* Corrigido o erro de aninhamento */
}

.toolbar::before {
    content: '';
    position: absolute;
    left: -50px;
    right: -50px;
    top: -200px;
    height: 200px;
    background: #f8f6f2;
    z-index: -1;
}

.toolbar input {
    font-size: 15px;
    width: 420px;
    padding: 12px 14px;
    border: 1px solid #c9a25d;
    border-radius: 8px;
    background: white;
}

.toolbar input:focus {
    outline: none;
    box-shadow: 0 0 8px rgba(201, 162, 93, 0.35);
}

/* =======================================
   Tabelas
   ======================================= */
.table-container {
    background: rgb(255, 255, 255);
    border: 1px solid #d1d5db;
    overflow: auto;
    max-height: 70vh;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th {
    font-size: 14px;
    background: linear-gradient(180deg, #07111f 0%, #0c1828 100%);
    color: #c9a25d;
    border: 1px solid #1e293b;
    padding: 8px;
    white-space: normal;
    position: sticky;
    top: 0;
    text-align: center;
    vertical-align: middle;
    font-weight: 600;
    letter-spacing: .5px;
}

td {
    font-size: 13px;
    border: 1px solid #d1d5db;
    padding: 6px;
    vertical-align: middle;
    text-align: center;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
}

.gaveta-tabela tbody tr:nth-child(even) {
    background: #faf7f0;
}

.gaveta-tabela tbody tr:hover td{

    background-image:
    linear-gradient(
        rgba(201,162,93,.18),
        rgba(201, 177, 45, 0.18)
    );

}

.linha-selecionada td{

    box-shadow:
    inset 0 2px 0 #c9a25d,
    inset 0 -2px 0 #c9a25d;

}

.gaveta-tabela tbody tr:hover td:first-child{

    box-shadow:
    inset 4px 0 0 #c9a25d,
    inset 0 2px 0 rgba(201,162,93,.35),
    inset 0 -2px 0 rgba(201,162,93,.35);

}

.gaveta-tabela tbody tr:hover td:last-child{

    box-shadow:
    inset -4px 0 0 #c9a25d,
    inset 0 2px 0 rgba(201,162,93,.35),
    inset 0 -2px 0 rgba(201,162,93,.35);

}

.gaveta-tabela tbody tr:hover{

    filter:brightness(1.05);

    outline:2px solid #c9a25d;

    outline-offset:-2px;

}

.cabecalho-gaveta {
    position: sticky;
    top: 60px;
    z-index: 95;
}

.cabecalho-gaveta:hover {
    box-shadow: 0 0 12px rgba(201, 162, 93, 0.18);
}

.cabecalho-colunas {
    position: sticky;
    top: 110px;
    z-index: 90;
}

.cabecalho-colunas th {
    background: #07111f;
}

/* Customização de Células Específicas na Gaveta */
.gaveta-tabela td,
.gaveta-tabela th {
    line-height: 1.15;
}

.gaveta-tabela td {
    height: auto;
    padding-top: 4px;
    padding-bottom: 4px;
}

.gaveta-tabela td:nth-child(2),
.gaveta-tabela td:nth-child(3) {
    white-space: nowrap !important;
}

.gaveta-tabela td:nth-child(10),
.gaveta-tabela td:nth-child(11),
.gaveta-tabela td:nth-child(14) {
    max-width: 0;
    text-align: left;
}

.gaveta-tabela td select,
.gaveta-tabela td input,
.gaveta-tabela td button {
    width: 100%;
    max-width: 100%;
}

.gaveta-tabela td select {
    min-width: 0;
    font-size: 13px; /* Consolidado para 13px conforme final do doc */
}

/* =======================================
   Inputs, Selects e Buttons Gerais
   ======================================= */
select {
    font-size: 13px;
    border: 1px solid #c9a25d;
    border-radius: 6px;
    padding: 4px 6px;
    background: #f4efe4;
    color: #07111f;
}

input[type="date"] {
    background: #f4efe4;
    border: 1px solid #c9a25d;
    border-radius: 6px;
    color: #07111f;
}

button {
    font-size: 13px;
    border: 1px solid #c9a25d;
    background: #c9a25d;
    color: white;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-weight: 600;
}

button:hover {
    background: #b88f47;
}

/* =======================================
   Modais
   ======================================= */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 999999;
}

.modal-content {
    background:#f8fafc;

    padding: 4px;

    width: 700px;

    max-width: 90vw;

    max-height: 85vh;

    overflow:auto;

    border-radius:16px;
    border:1px solid rgba(201,162,39,.25);

    box-shadow:
    0 20px 50px rgba(0,0,0,.35);
}

.modal-content > *:last-child{
    margin-bottom:0;
}

.titulo-modal {
    background: linear-gradient(180deg, #07111f 0%, #0c1828 100%);
    color: #c9a25d;
    margin: -20px -20px 20px -20px;
    padding: 24px;
    text-align: center;
    font-size: 30px;
    font-weight: 700;
    border-radius: 8px 8px 0 0;
}

.secao-modal {
    margin-top: 18px;
    margin-bottom: 8px;
    color: #07111f;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 2px;
    border-bottom: 1px solid #d6c08d;
    padding-bottom: 4px;
}

.modal-content h4 {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #c9a25d;
    margin: 20px 0 10px 0;
    border-bottom: 1px solid #e6d3aa;
    padding-bottom: 6px;
}

.modal-content input,
.modal-content select {
    width: 100%;
    border: 1px solid #d6c08d;
    border-radius: 8px;
    padding: 14px;
    font-size: 16px;
    margin-bottom: 10px;
    background: white;
}

.modal-content input:focus,
.modal-content select:focus {
    outline: none;
    border-color: #c9a25d;
    box-shadow: 0 0 8px rgba(201, 162, 93, 0.25);
}

/* =======================================
   Utilitários e Ajustes
   ======================================= */
.texto-longo {
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.2;
}

[id^="chave-"] {
    margin-bottom: 80px;
}

/* ==========================================
   PLANILHA PREMIUM
========================================== */

.gaveta-tabela{
    border-collapse:collapse;
}

.gaveta-tabela tbody tr{
    transition:
    transform .15s ease,
    box-shadow .15s ease,
    filter .15s ease;
     border-bottom:8px solid #e9f0d3;

    user-select:text;
}

.gaveta-tabela td{
    user-select:text;

    border-top:1px solid rgba(0,0,0,.04);
    border-bottom:1px solid rgba(0,0,0,.04);
}

/* cantos arredondados */

.gaveta-tabela tbody td:first-child{
    border-radius:10px 0 0 10px;
}

.gaveta-tabela tbody td:last-child{
    border-radius:0 10px 10px 0;
}

#tituloPlanilha{

    margin-top:18px;
    margin-bottom:0px;

    padding-left:6px;

    font-size:28px;
    font-weight:800;

    color:#07111f;

}