    /* Título Principal */
    .page-header {
        margin-bottom: 10px;
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
    }

    .page-header h1 {
        font-size: 1.8rem;
        font-weight: 700;
    }

    .page-header p {
        color: var(--text-muted);
        font-size: var(--text-2);
        margin-top: 5px;
    }

    /* Card Principal da Tabela */
    .dashboard-card {
        background: var(--branco);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        border: 1px solid var(--border);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 10px 10px;
        height: calc(100vh - 40px);
        
    }
   
    /* Toolbar Interna */
    .card-toolbar {
        padding: 2px 10px;
        display: flex;
        justify-content: space-between;
        align-items: center;
       
    }

    .card-title-internal {
        font-size: var(--text-3);
        font-weight: 800;
        text-transform: uppercase;
        color: var(--text-muted);
        letter-spacing: 0.5px;
        border-left: 3px solid var(--azul);
        padding-left: 4px;
    }

    .actions-right {
        margin-left: auto;
        display: flex;
        gap: 12px;
        align-items: flex-end;
    }
     
    /* MODAIS - apenas modal de cadastro (overlay) */
    .overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(4px);
        display: none;
        justify-content: center;
        align-items: center;
        z-index: 2000;
    }
    .overlay.active { display: flex; }

    .overlay .modal {
        background: var(--branco);
        width: 98%;
        max-width: min(1300px, 98vw);
        max-height: 90vh;
        min-width: 0;
        border-radius: 20px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-shadow: 0 25px 50px rgba(0,0,0,0.15);
        animation: modalIn 0.3s ease-out;
    }

    /* Garantir layout flex interno quando há <form> envolvendo o conteúdo */
    .overlay .modal form {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }

    @keyframes modalIn {
        from { transform: scale(0.97); opacity: 0; }
        to { transform: scale(1); opacity: 1; }
    }

    .overlay .modal-header {
        padding: 20px 30px;
        background: #fafafa;
        border-bottom: 1px solid var(--border);
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-transform: uppercase;
    }

    .overlay .modal-body { 
        flex: 1; 
        overflow-y: auto; 
        padding: 30px; 
        background: #fff; 
    }

    .overlay .modal-body::-webkit-scrollbar { width: 8px; }
    .overlay .modal-body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 10px; }

    /* Secções do Modal (cadastro) */
    .overlay .section-panel {
        background: var(--branco);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 20px;
        margin-bottom: 5px;
    }

    .overlay .section-title {
        font-size: var(--text-3);
        font-weight: 800;
        margin-bottom: 25px;
        color: var(--accent);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    

    /* Inputs do Modal (Split Label Compacto - ALTURA 32px) */
    .overlay .form-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 8px;
    }

    .overlay .form-grid-vertical {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .overlay .input-container {
        display: flex;
        width: 100%;
        align-items: center;
        background: var(--branco);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        display: flex;
        align-items: center;
        min-height: 32px;
        overflow: hidden;
        transition: border-color 0.2s;
    }

    .overlay .input-container:focus-within { border-color: #999; }

    /* Modal cadastro: form e grid estáveis ao redimensionar (min-width: 0 + largura 100%) */
    .overlay .modal .modal-cadastro-form {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .overlay .modal .modal-cadastro-form .modal-body {
        min-width: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .overlay .modal .modal-cadastro-form .section-panel {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .overlay .modal .modal-cadastro-form .form-grid {
        display: grid;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
        gap: 12px;
    }

    /* Flex: recalcula melhor que grid max-content/1fr ao ampliar a janela */
    .overlay .modal .modal-cadastro-form .input-container {
        display: flex;
        flex-direction: row;
        align-items: stretch;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        min-height: 2.4rem;
        box-sizing: border-box;
    }

    .overlay .modal .modal-cadastro-form .input-container.col-span-2 {
        grid-column: span 2;
    }

    .overlay .modal .modal-cadastro-form .split-label {
        flex: 0 0 auto;
        white-space: nowrap;
        word-break: normal;
        overflow-wrap: normal;
        align-self: center;
        padding: 0 12px;
        box-sizing: border-box;
    }

    .overlay .modal .modal-cadastro-form .input-value-wrap {
        display: flex;
        flex-direction: column;
        flex: 1 1 0%;
        min-width: 0;
        width: auto;
        max-width: 100%;
        justify-content: center;
        align-items: flex-start;
        gap: 4px;
        padding: 0 12px 0 10px;
        box-sizing: border-box;
        overflow: hidden;
    }

    .overlay .modal .modal-cadastro-form .input-value-wrap .error-text {
        color: #c62828;
        font-size: 12px;
        line-height: 1.25;
    }

    .overlay .modal .modal-cadastro-form .input-container:has(input[type="checkbox"]) {
        align-items: center;
    }

    .overlay .modal .modal-cadastro-form .input-container:has(input[type="checkbox"]) .input-value-wrap {
        flex-direction: row;
        align-items: center;
    }

    .overlay .split-label {          
        background: var(--fundo-label-cadastros);
        font-size: var(--text);
        font-weight: 800;
        padding: 0 15px;
        display: flex;
        align-items: center;
        border-right: 1px solid var(--border);
        min-width: fit-content;
        color:var(--text-muted);
        white-space: nowrap;
        height: 100%;
        text-transform: uppercase;
        
    }

    /* Labels Maiores para ficheiros empilhados */
    .overlay .form-grid-vertical .split-label {
        min-width: fit-content;
    }

    /* Mesmo estilo split-label fora do overlay (ex.: página contratos) */
    .section-panel .form-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 12px;
    }
    .section-panel .input-container {
        background: var(--branco);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        display: flex;
        align-items: center;
        min-height: 32px;
        overflow: hidden;
        transition: border-color 0.2s;
    }
    .section-panel .input-container:focus-within { border-color: var(--text-muted); }
    .section-panel .split-label {
        background: var(--fundo-label-cadastros);
        font-size: var(--text);
        font-weight: 800;
        padding: 0 10px;
        display: flex;
        align-items: center;
        border-right: 1px solid var(--border);
        min-width: fit-content;
        color:var(--preto);
        white-space: nowrap;
        height: 100%;
        text-transform: uppercase;
    }
    .section-panel input[type="text"],
    .section-panel input[type="number"],
    .section-panel input[type="email"],
    .section-panel input[type="date"],
    .section-panel select {
        border: none;
        outline: none;
        padding: 4px 12px;
        width: 100%;
        font-size: var(--text);
        background: transparent;
    }

    .overlay .modal-body input[type="text"],
    .overlay .modal-body input[type="number"],
    .overlay .modal-body input[type="email"],
    .overlay .modal-body input[type="date"],
    .overlay .modal-body select,
    .overlay .modal-body textarea {
       
       
        width: auto; 
        min-width: 0;
        flex: 1;
        border: none;
        background: transparent;
        padding: 4px 12px;
        }

    /* Largura próxima ao texto: field-sizing (Chrome 123+); fallback = width 100% */
    .overlay .modal .modal-cadastro-form .modal-body input:not([type="checkbox"]):not([type="file"]):not([type="hidden"]),
    .overlay .modal .modal-cadastro-form .modal-body select,
    .overlay .modal .modal-cadastro-form .modal-body textarea {
        box-sizing: border-box !important;
        max-width: 100% !important;
        min-width: 0 !important;
        flex: 0 1 auto !important;
    }

    @supports (field-sizing: content) {
        .overlay .modal .modal-cadastro-form .modal-body input:not([type="checkbox"]):not([type="file"]):not([type="hidden"]),
        .overlay .modal .modal-cadastro-form .modal-body select,
        .overlay .modal .modal-cadastro-form .modal-body textarea {
            field-sizing: content !important;
            width: auto !important;
            min-width: min(10ch, 100%) !important;
        }
    }

    @supports not (field-sizing: content) {
        .overlay .modal .modal-cadastro-form .modal-body input:not([type="checkbox"]):not([type="file"]):not([type="hidden"]),
        .overlay .modal .modal-cadastro-form .modal-body select,
        .overlay .modal .modal-cadastro-form .modal-body textarea {
            width: 100% !important;
            flex: 1 1 0% !important;
        }
    }

    .overlay .modal-body textarea {
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 12px;
        resize: vertical;
    }

    .overlay .field-label {
        font-size: var(--text);
        font-weight: 700;
        color: #888;
        margin-bottom: 4px;
        display: block;
    }

    .col-span-2 {
        grid-column: span 2; /* Faz o campo ocupar o espaço de 2 colunas */
    }

    /* Estilização File Input */
    .overlay .modal-body input[type="file"]::file-selector-button {
        border: none;
        background: #eee;
        padding: 4px 12px;
        border-radius: var(--radius);
        color: #444;
        font-weight: 700;
        font-size: var(--text);
        text-transform: uppercase;        
        margin-right: 10px;
    }

    .overlay .modal-footer { padding: 20px 30px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

    .radio{
        background: var(--bg-card) !important;
        padding: 10px 10px;
        border-radius: var(--radius);
        display: flex;
        width: fit-content;
        gap: 5px;
        border: 1px solid var(--border);
        margin: 2px 0;
    }

    .radio-item {
        padding: 8px 10px;
        border-radius: var(--radius);
        font-size: var(--text);
        font-weight: 700;
        color: var(--text-muted);
        transition: all 0.2s;
        text-transform: uppercase;
    }

    .radio-item:has(input:checked) {
        background: var(--branco);
        color: var(--preto);
        box-shadow: var(--shadow);
    }

    .radio-item input { display: none; }

    .label-main-text {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: var(--text);
        font-weight: 800;
        color: var(--text-main);
        text-transform: uppercase;
        white-space: nowrap;
    }

    .cadastro-form-grid {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
        margin: 2px 0 2px 0;
    }

    /* Página Contratos (scroll, editor, lista) */
    .main-scroll-wrapper {
        height: calc(100vh - 100px);
        overflow-y: auto;
        padding-right: 10px;
        padding-bottom: 60px;
    }
    .main-scroll-wrapper::-webkit-scrollbar { width: 6px; }
    .main-scroll-wrapper::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }

    .label-row-custom {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
    }
    .add-text-link {
        font-size: 0.7rem;
        color: var(--azul);
        font-weight: 700;
    }


    .page-header-title {
        font-size: var(--text-3);
        font-weight: 800;
        text-transform: uppercase;
        color: var(--azul);
        letter-spacing: 0.5px;     
        margin-top: 0 !important;
    }
    
    .tabs-nav-container {
        margin: 0 0 2px 0;
        display: flex;
        justify-content: flex-start;
    }

    .tab-content { display: none; }
    .tab-content.active { display: block; animation: fadeIn 0.3s ease; }

    .log-panel-terminal {
        background-color: #1a1a1a;
        color: #00ff41; /* Verde clássico de terminal */       
        padding: 20px;
        border-radius: 12px;
        height: 480px;
        overflow-y: auto;
        border: 1px solid #333;
        box-shadow: inset 0 2px 15px rgba(0,0,0,0.6);
        font-size: 0.8rem;
        line-height: 1.5;
    }

    .log-panel-terminal::-webkit-scrollbar { width: 8px; }
    .log-panel-terminal::-webkit-scrollbar-thumb { background: #444; border-radius: 10px; }

    /* Estilo para as abas (Segmented Control) */
    
    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(5px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .form-description {
        font-size: var(--text-2);
        color: var(--text-muted);
        margin-bottom: 20px;
        line-height: 1.5;
    }

    
    .dropdown-small {
        background: var(--bg-card);
        border: 1px solid var(--border);
        padding: 8px 12px;
        border-radius: var(--radius);
        font-size: var(--text);
        font-weight: 500;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        text-transform: uppercase;
    }
    
    
    
    .tabs-nav-container .actions-right {
        margin-left: auto;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .input-value-wrap {
        flex: 1;
        min-width: 0;
    }